Hair-pencil
Hair-pencils and coremata are pheromone signaling structures present in lepidopteran males. Males use hair-pencils in courtship behaviors with females. The pheromones they excrete serve as both aphrodisiacs and tranquilizers to females as well as repellents to conspecific males. Hair-pencil glands are stored inside the male until courtship begins, at which point they are forced out of the body by sclerotized levers present on the abdomen. Coremata (the singular form being corema) are very similar structures. Their exact definition is confused by early descriptions but they are more specifically defined as the internal, glandular, eversible structures that bear the hair-pencils and can be voluntarily inflated with hemolymph or air. Behavioral use of hair-pencils
Male moths are attracted from relatively long distances by females releasing pheromones; when they are close enough to the females to begin courtship, the hair-pencils are extruded from the abdominal cavity and pheromones are fanned towards the female. Fanning can occur in various ways including extruding and retracting the hair-pencils, wing or abdominal movement, or flight in front of the female. When the female moth becomes receptive to the male hair-penciling, she will flick her antennas rapidly in response to his pheromone cues. If the female likes the male blend of pheromones, then she will extend her abdomen and copulation begins. Hair-pencil pheromone effects

It has been shown  that the hair-pencil pheromones serve both as an aphrodisiac or tranquilizer for the female, but sometimes as a repellent to other conspecific males. In an experiment with heliothine moths, male hair-pencil compounds were extracted and tested against various male and female treatments. It was found that not one specific compound triggered a response in females, but a blend was required. Additionally it is thought that the specific ratio of each of the compounds found in the male moths helps females determine a suitable male from her species. Heliothine moths use similar hair-pencil compounds in different ratios and this is enough for the female to differentiate conspecifics from other species. Males are able to detect competitors through hair-pencil compounds, but extra competitors do not cause great increases in display rate. This perhaps is due to the suppressing effect of hair-pencil pheromones on competitors. Pheromones have also been demonstrated to show the age of the male. As males age the pheromone chemical ratios change slightly. Females can distinguish between males by these changes and pick a more suitable mate. Plants and insect relations
Some of the pheromone compounds that are produced in the hair-pencils of the insects have been found to come from plants . In particular, pyrrolizidine alkaloids have been found to play a role in male pheromones. These compounds can be formed by de novo synthesis or by modifying a pre-existing pyrrolizidine alkaloid that is consumed from the plant. These base compounds can be either eaten in the larval stage or imbibed in the adult stage. They are so important that stepping on a substance containing these compounds causes immediate proboscis extension in adults. Studies have also been done testing the effects of growth of the hair-pencil organs related to the ingestion of plant pyrrolizidine alkaloids. It was found that without the plant derived compounds the hair-pencil organs are smaller. The alkaloid compounds are transformed after ingestion in the hemolymph. The stimulatory effects of the alkaloid derived compounds begin in the larval stages and are displayed in adult stages. References 

Lepidopterology
Insect anatomy