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.MailAddress; 23 import org.apache.mailet.MailetException; 24 25 import javax.mail.Address ; 26 import javax.mail.Message ; 27 import javax.mail.MessagingException ; 28 import javax.mail.Session ; 29 import javax.mail.internet.InternetAddress ; 30 import javax.mail.internet.MimeBodyPart ; 31 import javax.mail.internet.MimeMessage ; 32 import javax.mail.internet.MimeMultipart ; 33 import java.io.IOException ; 34 import java.io.PrintWriter ; 35 import java.io.StringWriter ; 36 import java.util.Date ; 37 import java.util.HashSet ; 38 import java.util.Set ; 39 import java.util.Collection ; 40 import java.util.Iterator ; 41 42 96 public class NotifyPostmaster extends AbstractNotify { 97 98 103 public String getMailetInfo() { 104 return "NotifyPostmaster Mailet"; 105 } 106 107 108 protected String [] getAllowedInitParameters() { 109 String [] allowedArray = { 110 "debug", 112 "passThrough", 113 "fakeDomainCheck", 114 "inline", 115 "attachment", 116 "message", 117 "notice", 118 "sender", 119 "sendingAddress", 120 "prefix", 121 "attachError", 122 "attachStackTrace", 123 "to" 124 }; 125 return allowedArray; 126 } 127 128 129 130 131 132 135 protected Collection getRecipients() { 136 Collection newRecipients = new HashSet (); 137 newRecipients.add(getMailetContext().getPostmaster()); 138 return newRecipients; 139 } 140 141 144 protected InternetAddress [] getTo() throws MessagingException { 145 String addressList = getInitParameter("to"); 146 InternetAddress [] iaarray = new InternetAddress [1]; 147 iaarray[0] = getMailetContext().getPostmaster().toInternetAddress(); 148 if (addressList != null) { 149 MailAddress specialAddress = getSpecialAddress(addressList, 150 new String [] {"postmaster", "unaltered"}); 151 if (specialAddress != null) { 152 iaarray[0] = specialAddress.toInternetAddress(); 153 } else { 154 log("\"to\" parameter ignored, set to postmaster"); 155 } 156 } 157 return iaarray; 158 } 159 160 165 protected boolean attachError() throws MessagingException { 166 String parameter = getInitParameter("attachStackTrace"); 167 if (parameter == null) { 168 return super.attachError(); 169 } 170 return new Boolean (parameter).booleanValue(); 171 } 172 173 174 175 176 177 } 178 179 | Popular Tags |