UCSF / AP

When she says no, the bottle beckons more brightly — for men and for fruit flies, according to a new study that found that male flies that had been repeatedly spurned by females were more likely to turn to alcohol to self-medicate their frustration.

As a topic of study, drunk fruit flies may seem trifling, but what the findings reveal about the neurochemistry that drives behaviors like sex and eating may point the way to new drugs to fight both addiction and obesity.

Researchers performed several clever experiments to determine the relationship between sexual frustration and drinking in male flies. Some lucky males were allowed four days of mating for six-hour sessions at a time (each bout of fruit fly copulation takes 20 minutes) with an abundance of sexually receptive females — the female-to-male ratio was a satisfying 5-to-1. The male flies were housed either together or alone.

The unlucky experimental group was introduced to females that had already mated and had no desire to mate again. The females ran away, kicked and stuck out their egg-laying organ to fend males off. The male flies underwent this exercise in sexual frustration and rejection three times a day, for an hour at a time, over four days. Again, some of the males were kept in containers with other male flies, while others were isolated.

A third group of males was exposed to the sad sight of decapitated virgin females — a situation that resulted in sexual frustration, but no active rejection.

MORE: Do Monkeys Pay for Sex?

After these experiences, the flies were given a choice of ordinary food (yeast and sugar) or food that had been spiked with the kick of 30-proof spirits (yeast, sugar and 15% alcohol). Not surprisingly, the sexually rejected flies boozed much more than the mated group — with those males that had been spurned and alone hitting the sauce the hardest. The flies that had been sexually frustrated but not rejected also drank more than those that had been allowed to mate. However, when flies that had first been rejected were later given a chance to mate, their extra preference for alcohol disappeared.

So what was going on in the flies’ brains? Researchers found that a neurotransmitter called neuropeptide F, or NPF, which seems to be linked with fruit flies’ reward system, was strongly predictive of whether the flies drank. NPF was low in sexually frustrated flies — lower in flies that had been isolated than in those that had company in their misery — which appeared to drive them to drink.

Both mating and drinking alcohol increased NPF levels. Moreover, when NPF levels were artificially reduced in mated flies, they continued to show an extra preference for alcohol — just as if they hadn’t mated. “These data suggest that activity of the NPF system is regulated by at least two rewarding experiences, mating and [alcohol] intoxication,” the authors write.

The researchers also found that activating the NPF system was itself pleasurable to the flies, suggesting that it may create the feeling of satisfaction associated with drinking and sex.

SPECIAL: Top 10 Weird Animal Mating Rituals

Humans do not have NPF, but our brains and those of other mammals do contain a related substance called neuropeptide Y, or NPY. In rodent studies, researchers have found that infusing NPY into the brain’s reward areas produces reactions similar to those seen with alcohol and other recreational drug use. It also has been shown to reduce anxiety and relieve the fear and distress that accompanies drug withdrawal.

NPY is also involved in the regulation of appetite and in the response to stress in humans. Reduced levels of the neurotransmitter are seen in people with depression and PTSD.

In a commentary humorously titled “She said No, Pass Me a Beer” that was published along with the new study in the journal Science, Troy Zars of the University of Missouri writes:

The authors provide new insights into a neural circuit that links a rewarding social interaction with a lasting change in behavioral preferences. Identifying the NPF system as critical in this linkage offers exciting prospects for determining the molecular and genetic mechanisms of reward and could potentially influence our understanding of the mechanisms of drugs of abuse.

MORE: LSD May Help Treat Alcoholism

Lead author Ulrike Heberlein, professor of anatomy and neurology at UCSF, who led the research, said in a statement: “If neuropeptide Y turns out to be the transducer between the state of the psyche and the drive to abuse alcohol and drugs, one could develop therapies to inhibit neuropeptide Y receptors.”

It bears noting, however, that prior strategies that have sought to block pleasure in order to fight addiction have been far less successful than those that offer a type of drug that acts similarly to the one that the addicted people seek. For example, maintaining addicts on methadone or buprenorphine — which act similarly to opioids like heroin and Oxycontin — has long been shown to be more successful than treating them with opioid-blocking drugs like naltrexone (implantable forms of naltrexone have not yet been directly compared).

So a drug that acts similarly to NPY could potentially turn out to be an excellent substance to fight addiction, depression and anxiety — but of course would also probably carry the risk of being addictive, just as methadone does. Only more studies will tell.

MORE: Heroin Cheaper, More Effective than Methadone For Hard Cases: Study

Maia Szalavitz is a health writer for TIME.com. Find her on Twitter at @maiasz. You can also continue the discussion on TIME Healthland‘s Facebook page and on Twitter at @TIMEHealthland.