1 17 18 package org.apache.james.transport.mailets; 19 20 import javax.mail.internet.MimeMessage ; 21 22 import org.apache.james.core.MailImpl ; 23 import org.apache.mailet.GenericMailet ; 24 import org.apache.mailet.Mail ; 25 26 38 public class AddHeader 39 extends GenericMailet { 40 41 44 private String headerName; 45 46 49 private String headerValue; 50 51 54 public void init() { 55 headerName = getInitParameter("name"); 56 headerValue = getInitParameter("value"); 57 } 58 59 66 public void service(Mail mail) { 67 try { 68 MimeMessage message = mail.getMessage () ; 69 70 message.setHeader(headerName, headerValue); 72 message.saveChanges(); 73 } catch (javax.mail.MessagingException me) { 74 log (me.getMessage()); 75 } 76 } 77 78 83 public String getMailetInfo() { 84 return "AddHeader Mailet" ; 85 } 86 87 } 88 89 | Popular Tags |