Abstract Mate recognition in animals evolves during niche adaptation and involves habitat and social olfactory signals. Drosophila melanogaster is attracted to fermenting fruit for feeding and egg-laying. We show that, in addition, female flies release a pheromone ( Z )-4-undecenal ( Z 4-11Al), that elicits flight attraction in both sexes. The biosynthetic precursor of Z 4-11Al is the cuticular hydrocarbon ( Z , Z )-7,11-heptacosadiene (7,11-HD), which is known to afford reproductive isolation between the sibling species D. melanogaster and D. simulans . A pair of alternatively spliced receptors, Or69aB and Or69aA, is tuned to Z 4-11Al and to food olfactory cues, respectively. These receptors are co-expressed in the same olfactory sensory neurons, and feed into a neural circuit mediating species-specific, long-range communication: the close relative D. simulans , which shares food resources and co-occurs with D. melanogaster , does not respond. That Or69aA and Or69aB have adopted dual olfactory traits highlights the interplay of habitat and social signals in mate finding. These olfactory receptor genes afford a collaboration between natural and sexual selection, which has the potential to drive phylogenetic divergence. Significance Statement Volatile insect sex pheromones carry a message over a distance, they are perceived by dedicated olfactory receptors, and elicit a sequence of innate behaviours. Pheromones mediate specific mate recognition, but are embedded in and perceived together with environmental olfactory cues. We have identified the first long-range, species-specific pheromone in Drosophila melanogaster. A pair of spliced olfactory receptors, feeding into the same neural circuit, has developed a dual affinity to this pheromone and kairomones, encoding adult and larval food. Blends of this pheromone and kairomone specifically attract D. melanogaster , but not the close relative D. simulans. This becomes an excellent paradigm to study the interaction of social signals and habitat olfactory cues in premating reproductive isolation and phylogenetic divergence.