FileDocCategorySizeDatePackage
ToProcessor.javaAPI DocApache James 2.3.13774Fri Jan 12 12:56:30 GMT 2007org.apache.james.transport.mailets

ToProcessor

public class ToProcessor extends org.apache.mailet.GenericMailet
This mailet redirects the mail to the named processor Sample configuration: spam Notice attached to the message (optional)

Fields Summary
private boolean
isDebug
Controls certain log messages
String
processor
The name of the processor to which this mailet forwards mail
String
noticeText
The error message to attach to the forwarded message
Constructors Summary
Methods Summary
public java.lang.StringgetMailetInfo()
Return a string describing this mailet.

return
a string describing this mailet

        return "ToProcessor Mailet";
    
public voidinit()
Initialize the mailet

throws
MailetException if the processor parameter is missing


                    
         
        isDebug = (getInitParameter("debug") == null) ? false : new Boolean(getInitParameter("debug")).booleanValue();
        processor = getInitParameter("processor");
        if (processor == null) {
            throw new MailetException("processor parameter is required");
        }
        noticeText = getInitParameter("notice");
    
public voidservice(org.apache.mailet.Mail mail)
Deliver a mail to the processor.

param
mail the mail to process
throws
MessagingException in all cases

        if (isDebug) {
            StringBuffer logBuffer =
                new StringBuffer(128)
                        .append("Sending mail ")
                        .append(mail)
                        .append(" to ")
                        .append(processor);
            log(logBuffer.toString());
        }
        mail.setState(processor);
        if (noticeText != null) {
            if (mail.getErrorMessage() == null) {
                mail.setErrorMessage(noticeText);
            } else {
                StringBuffer errorMessageBuffer =
                    new StringBuffer(256)
                            .append(mail.getErrorMessage())
                            .append("\r\n")
                            .append(noticeText);
                mail.setErrorMessage(errorMessageBuffer.toString());
            }
        }