1 17 18 package org.apache.james.transport.mailets; 19 20 import org.apache.mailet.GenericMailet; 21 import org.apache.mailet.Mail; 22 import org.apache.mailet.MailetException; 23 24 import javax.mail.MessagingException ; 25 26 36 public class ToProcessor extends GenericMailet { 37 38 41 private boolean isDebug = false; 42 43 46 String processor; 47 48 51 String noticeText = null; 52 53 58 public void init() throws MailetException { 59 isDebug = (getInitParameter("debug") == null) ? false : new Boolean (getInitParameter("debug")).booleanValue(); 60 processor = getInitParameter("processor"); 61 if (processor == null) { 62 throw new MailetException("processor parameter is required"); 63 } 64 noticeText = getInitParameter("notice"); 65 } 66 67 74 public void service(Mail mail) throws MessagingException { 75 if (isDebug) { 76 StringBuffer logBuffer = 77 new StringBuffer (128) 78 .append("Sending mail ") 79 .append(mail) 80 .append(" to ") 81 .append(processor); 82 log(logBuffer.toString()); 83 } 84 mail.setState(processor); 85 if (noticeText != null) { 86 if (mail.getErrorMessage() == null) { 87 mail.setErrorMessage(noticeText); 88 } else { 89 StringBuffer errorMessageBuffer = 90 new StringBuffer (256) 91 .append(mail.getErrorMessage()) 92 .append("\r\n") 93 .append(noticeText); 94 mail.setErrorMessage(errorMessageBuffer.toString()); 95 } 96 } 97 } 98 99 104 public String getMailetInfo() { 105 return "ToProcessor Mailet"; 106 } 107 } 108 | Popular Tags |