class UseHeaderRecipients extends GenericMailet {

    @Override
    public void service(Mail mail) throws MessagingException {
        MimeMessage message = mail.getMessage();

        mail.setRecipients(headersAddresses(message));

        if (isDebug) {
            LOGGER.debug("All recipients = {}", mail.getRecipients());
            LOGGER.debug("Reprocessing mail using recipients in message headers");
        }

        // Return email to the "root" process.
        getMailetContext().sendMail(mail.duplicate());
        mail.setState(Mail.GHOST);
    }

}