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 24 import javax.mail.MessagingException ; 25 import javax.mail.internet.InternetAddress ; 26 import java.util.Collection ; 27 import java.util.HashSet ; 28 29 59 public class Forward extends AbstractRedirect { 60 61 66 public String getMailetInfo() { 67 return "Forward Mailet"; 68 } 69 70 71 protected String [] getAllowedInitParameters() { 72 String [] allowedArray = { 73 "debug", 75 "passThrough", 76 "fakeDomainCheck", 77 "forwardto", 78 "forwardTo" 79 }; 80 return allowedArray; 81 } 82 83 84 85 86 87 90 protected int getInLineType() throws MessagingException { 91 return UNALTERED; 92 } 93 94 97 protected int getAttachmentType() throws MessagingException { 98 return NONE; 99 } 100 101 104 protected String getMessage() throws MessagingException { 105 return ""; 106 } 107 108 111 protected Collection getRecipients() throws MessagingException { 112 Collection newRecipients = new HashSet (); 113 boolean error = false; 114 String addressList = getInitParameter("forwardto"); 115 if (addressList == null) { 116 addressList = getInitParameter("forwardTo"); 117 } 118 119 if (addressList == null) { 121 throw new MessagingException ("Failed to initialize \"recipients\" list: no <forwardTo> or <forwardto> init parameter found"); 122 } 123 124 try { 125 InternetAddress [] iaarray = InternetAddress.parse(addressList, false); 126 for (int i = 0; i < iaarray.length; i++) { 127 String addressString = iaarray[i].getAddress(); 128 MailAddress specialAddress = getSpecialAddress(addressString, 129 new String [] {"postmaster", "sender", "from", "replyTo", "reversePath", "unaltered", "recipients", "to", "null"}); 130 if (specialAddress != null) { 131 newRecipients.add(specialAddress); 132 } else { 133 newRecipients.add(new MailAddress(iaarray[i])); 134 } 135 } 136 } catch (Exception e) { 137 throw new MessagingException ("Exception thrown in getRecipients() parsing: " + addressList, e); 138 } 139 if (newRecipients.size() == 0) { 140 throw new MessagingException ("Failed to initialize \"recipients\" list; empty <recipients> init parameter found."); 141 } 142 143 return newRecipients; 144 } 145 146 149 protected InternetAddress [] getTo() throws MessagingException { 150 return null; 151 } 152 153 156 protected MailAddress getReplyTo() throws MessagingException { 157 return null; 158 } 159 160 163 protected MailAddress getReversePath() throws MessagingException { 164 return null; 165 } 166 167 170 protected MailAddress getSender() throws MessagingException { 171 return null; 172 } 173 174 177 protected String getSubject() throws MessagingException { 178 return null; 179 } 180 181 184 protected String getSubjectPrefix() throws MessagingException { 185 return null; 186 } 187 188 191 protected boolean attachError() { 192 return false; 193 } 194 195 198 protected boolean isReply() throws MessagingException { 199 return false; 200 } 201 202 203 204 205 206 } 207 208 | Popular Tags |