FileDocCategorySizeDatePackage
SetMimeHeaderHandler.javaAPI DocApache James 2.3.13423Fri Jan 12 12:56:26 GMT 2007org.apache.james.smtpserver

SetMimeHeaderHandler

public class SetMimeHeaderHandler extends org.apache.avalon.framework.logger.AbstractLogEnabled implements MessageHandler, org.apache.avalon.framework.configuration.Configurable
Adds the header to the message

Fields Summary
private String
headerName
The header name and value that needs to be added
private String
headerValue
Constructors Summary
Methods Summary
public voidconfigure(org.apache.avalon.framework.configuration.Configuration handlerConfiguration)

see
org.apache.avalon.framework.configuration.Configurable#configure(Configuration)


        Configuration configuration = handlerConfiguration.getChild("headername", false);
        if(configuration != null) {
            setHeaderName(configuration.getValue());
        }

        configuration = handlerConfiguration.getChild("headervalue", false);
        if(configuration != null) {
            setHeaderValue(configuration.getValue());
        }
    
public voidonMessage(SMTPSession session)
Adds header to the message

see
org.apache.james.smtpserver#onMessage(SMTPSession)

        try {
            MimeMessage message = session.getMail().getMessage ();

            //Set the header name and value (supplied at init time).
            if(headerName != null) {
                message.setHeader(headerName, headerValue);
                message.saveChanges();
            }

        } catch (javax.mail.MessagingException me) {
            getLogger().error(me.getMessage());
        }
    
public voidsetHeaderName(java.lang.String headerName)
Set the header name

param
headerName String which represent the header name

        this.headerName = headerName;
    
public voidsetHeaderValue(java.lang.String headerValue)
Set the header value

param
headerValue String wich represetn the header value

        this.headerValue = headerValue;