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 95 public class NotifySender extends AbstractNotify { 96 97 102 public String getMailetInfo() { 103 return "NotifySender Mailet"; 104 } 105 106 107 protected String [] getAllowedInitParameters() { 108 String [] allowedArray = { 109 "debug", 111 "passThrough", 112 "fakeDomainCheck", 113 "inline", 114 "attachment", 115 "message", 116 "notice", 117 "sender", 118 "sendingAddress", 119 "prefix", 120 "attachError", 121 "attachStackTrace", 122 "to" 123 }; 124 return allowedArray; 125 } 126 127 128 129 130 131 134 protected Collection getRecipients() { 135 Collection newRecipients = new HashSet (); 136 newRecipients.add(SpecialAddress.SENDER); 137 return newRecipients; 138 } 139 140 143 protected InternetAddress [] getTo() throws MessagingException { 144 String addressList = getInitParameter("to"); 145 InternetAddress [] iaarray = new InternetAddress [1]; 146 iaarray[0] = SpecialAddress.SENDER.toInternetAddress(); 147 if (addressList != null) { 148 MailAddress specialAddress = getSpecialAddress(addressList, 149 new String [] {"sender", "unaltered", "from"}); 150 if (specialAddress != null) { 151 iaarray[0] = specialAddress.toInternetAddress(); 152 } else { 153 log("\"to\" parameter ignored, set to sender"); 154 } 155 } 156 return iaarray; 157 } 158 159 164 protected boolean attachError() throws MessagingException { 165 String parameter = getInitParameter("attachStackTrace"); 166 if (parameter == null) { 167 return super.attachError(); 168 } 169 return new Boolean (parameter).booleanValue(); 170 } 171 172 173 174 175 176 } 177 178 | Popular Tags |