1 17 18 package org.apache.james.transport.mailets; 19 20 import org.apache.james.util.RFC2822Headers; 21 import org.apache.mailet.GenericMailet; 22 import org.apache.mailet.Mail; 23 import org.apache.mailet.MailAddress; 24 import org.apache.mailet.MailetException; 25 26 import javax.mail.Address ; 27 import javax.mail.Message ; 28 import javax.mail.MessagingException ; 29 import javax.mail.Session ; 30 import javax.mail.internet.InternetAddress ; 31 import javax.mail.internet.MimeBodyPart ; 32 import javax.mail.internet.MimeMessage ; 33 import javax.mail.internet.MimeMultipart ; 34 import java.io.IOException ; 35 import java.io.PrintWriter ; 36 import java.io.StringWriter ; 37 import java.util.Date ; 38 import java.util.HashSet ; 39 import java.util.Set ; 40 import java.util.Collection ; 41 import java.util.Iterator ; 42 import java.util.ArrayList ; 43 44 100 public class Bounce extends AbstractNotify { 101 102 107 public String getMailetInfo() { 108 return "Bounce Mailet"; 109 } 110 111 112 protected String [] getAllowedInitParameters() { 113 String [] allowedArray = { 114 "debug", 116 "passThrough", 117 "fakeDomainCheck", 118 "inline", 119 "attachment", 120 "message", 121 "notice", 122 "sender", 123 "sendingAddress", 124 "prefix", 125 "attachError", 126 }; 127 return allowedArray; 128 } 129 130 131 132 133 134 137 protected Collection getRecipients() { 138 Collection newRecipients = new HashSet (); 139 newRecipients.add(SpecialAddress.REVERSE_PATH); 140 return newRecipients; 141 } 142 143 146 protected InternetAddress [] getTo() { 147 InternetAddress [] apparentlyTo = new InternetAddress [1]; 148 apparentlyTo[0] = SpecialAddress.REVERSE_PATH.toInternetAddress(); 149 return apparentlyTo; 150 } 151 152 155 protected MailAddress getReversePath(Mail originalMail) { 156 return SpecialAddress.NULL; 157 } 158 159 160 161 162 163 171 public void service(Mail originalMail) throws MessagingException { 172 MailAddress returnAddress = getExistingReturnPath(originalMail); 173 if (returnAddress == SpecialAddress.NULL) { 174 if (isDebug) 175 log("Processing a bounce request for a message with an empty reverse-path. No bounce will be sent."); 176 if(!getPassThrough(originalMail)) { 177 originalMail.setState(Mail.GHOST); 178 } 179 return; 180 } else if (returnAddress == null) { 181 log("WARNING: Mail to be bounced does not contain a reverse-path."); 182 } else { 183 if (isDebug) 184 log("Processing a bounce request for a message with a return path header. The bounce will be sent to " + returnAddress); 185 } 186 super.service(originalMail); 187 } 188 189 } 190 191 | Popular Tags |