PostmasterAlias.javaAPI DocApache James 2.3.13501Fri Jan 12 12:56:30 GMT 2007org.apache.james.transport.mailets


public class PostmasterAlias extends org.apache.mailet.GenericMailet
Rewrites recipient addresses to make sure email for the postmaster is always handled. This mailet is silently inserted at the top of the root spool processor. All recipients mapped to postmaster@ are changed to the postmaster account as specified in the server conf.

Fields Summary
Constructors Summary
Methods Summary
public java.lang.StringgetMailetInfo()
Return a string describing this mailet.

a string describing this mailet

        return "Postmaster aliasing mailet";
public voidservice(org.apache.mailet.Mail mail)
Make sure that a message that is addressed to a postmaster alias is always sent to the postmaster address, regardless of delivery to other recipients.

mail the mail to process
MessagingException if an error is encountered while modifying the message

        Collection recipients = mail.getRecipients();
        Collection recipientsToRemove = null;
        MailetContext mailetContext = getMailetContext();
        boolean postmasterAddressed = false;

        for (Iterator i = recipients.iterator(); i.hasNext(); ) {
            MailAddress addr = (MailAddress);
            if (addr.getUser().equalsIgnoreCase("postmaster") &&
                mailetContext.isLocalServer(addr.getHost())) {
                //Should remove this address... we want to replace it with
                //  the server's postmaster address
                if (recipientsToRemove == null) {
                    recipientsToRemove = new Vector();
                //Flag this as having found the postmaster
                postmasterAddressed = true;
        if (postmasterAddressed) {