I was looking into creating my own MailListener like:
public class BlueSpaceJBossMailListener extends BlueSpaceMessageDriveBean implements MailListener { /* Methods for constructing new instances. */ public BlueSpaceJBossMailListener () { super(); } /* Methods that satisfy the MailListener interface. */ public Message send (Message message) throws MailException { Logger.SMAIL.debug("Message received from JBoss Mail Server."); Mail mail = (Mail) message; Logger.SMAIL.debug("Subject:" + this.getSubject(mail)); Logger.SMAIL.debug("From:" + mail.getFrom().getRawAddress()); Logger.SMAIL.debug("Recipients:"); List<EnvelopedAddress> recipients = mail.getRecipients(); for (EnvelopedAddress address : recipients) { Logger.SMAIL.debug (address.getType().toString() + ':' + address.getRawAddress()); } return message; } /* Keep out! */ /* Constants */ /* None at this time. */ protected String getSubject (Mail mail) { String[] subjects = mail.getHeader("Subject"); if (subjects == null || subjects.length == 0) { return null; } else { return subjects[0]; } } /* Class variables */ /* None at this time. */ /* Instance variables */ /* None at this time. */ }
The Mail Server APIs have grown a bit organically over time and Message Interface could do with some work. The simplest solution would probably be to add relevant method signatures from the Mail class, to the Message interface.
Patches are welcome...
Mike.