Return-Path:
TRUE or FALSE. If this is TRUE it tells the mailet that it can
@@ -220,6 +204,8 @@
*their values. This will boost performance where a redirect task
*doesn't contain any dynamic values. If this is FALSE, it tells the
*mailet to recalculate the values for each e-mail processed. Note: If you use "magic words" such as "sender" in the <sender>
+*tag, you must NOT use set static to TRUE. This defaults to false.A comma delimited list of email addresses for recipients of
*this message, it will use the "to" list if not specified. These
*addresses will only appear in the To: header if no "to" list is
-*supplied.
+*supplied.
*
*
-*It can include constants "sender" and "postmaster"
*
*<to>
*A comma delimited list of addresses to appear in the To: header,
*the email will only be delivered to these addresses if they are in the recipients
*list.
+*The recipients list will be used if this is not supplied.
*
-*The recipients list will be used if this is not supplied.
-*It can include constants "sender", "postmaster" and "unaltered"
*
*<sender>
@@ -191,15 +186,9 @@
*
*
-*<replyto>
-*A single email address to appear in the Reply-To: header, can
+* A single email address to appear in the Rely-To: header, can
*also be "sender" or "postmaster", this header is not
-*set if this is omitted.
-*
-*
*<returnPath>
-*A single email address to appear in the Return-Path: header, can
-*also be "sender" or "postmaster" or "null"; this header is not
-*set if this parameter is omitted.
+*set if this is omited.
*
*
*<prefix>
@@ -208,11 +197,6 @@
*Undeliverable mail:
*
-*
-*<isReply>
-*TRUE or FALSE, if true the IN_REPLY_TO header will be set to the
-*id of the current message.
-*
*
@@ -254,127 +240,69 @@
*<static>TRUE</static><static>
*
*
*
*
*</mailet>
passThrough
init parameter.
+ * returns one of these values to indicate how to attach the original message
+ *static
init parameter.
- * return true to reduce calls to getTo, getSender, getRecipients, getReplyTo, getReturnPath amd getMessage
- * where these values don't change (eg hard coded, or got at startup from the mailet config)inline
init parameter.
- * May return one of the following values to indicate how to append the original message
- * to build the new message:
- * inline
init parameter,
- * built dynamically using the original Mail object.
- * Is a "getX(Mail)" method.
- *
- * @return {@link #getInlineType()}
- */
- protected int getInLineType(Mail originalMail) throws MessagingException {
- int inLineType = (isStatic()) ? this.inLineType : getInLineType();
- return inLineType;
- }
-
- /**
- * Gets the attachment
init parameter.
- * May return one of the following values to indicate how to attach the original message
- * to the new message:
- * attachment
init parameter,
- * built dynamically using the original Mail object.
- * Is a "getX(Mail)" method.
+ * Return a string describing this mailet.
*
- * @return {@link #getAttachmentType()}
+ * @return a string describing this mailet
*/
- protected int getAttachmentType(Mail originalMail) throws MessagingException {
- int attachmentType = (isStatic()) ? this.attachmentType : getAttachmentType();
- return attachmentType;
+ public String getMailetInfo() {
+ return "Resend Mailet";
}
/**
- * Gets the message
init parameter.
- * Returns a message to which the original message can be attached/appended
- * to build the new message.
- * Is a "getX()" method.
- *
- * @return the message or an empty string if parameter is missing
+ * must return either an empty string, or a message to which the redirect can be attached/appended
*/
- protected String getMessage() throws MessagingException {
+ public String getMessage() {
if(getInitParameter("message") == null) {
return "";
} else {
@@ -446,44 +331,25 @@
}
/**
- * Gets the message
init parameter,
- * built dynamically using the original Mail object.
- * Is a "getX(Mail)" method.
- *
- * @return {@link #getMessage()}
+ * return true to allow thie original message to continue through the processor, false to GHOST it
*/
- protected String getMessage(Mail originalMail) throws MessagingException {
- String messageText = (isStatic()) ? this.messageText : getMessage();
- return messageText;
+ public boolean getPassThrough() {
+ if(getInitParameter("passThrough") == null) {
+ return false;
+ } else {
+ return new Boolean(getInitParameter("passThrough")).booleanValue();
+ }
}
-
+
/**
- * Gets the recipients
init parameter.
- * Returns the collection of recipients of the new message.
- * If the recipients
init parameter is missing,
- * returns the to
init parameter.
- * Is a "getX()" method.
- *
- * @return the addresses or SENDER or null if missing
+ * must return a Collection of recipient MailAddresses
*/
- protected Collection getRecipients() throws MessagingException {
- Collection newRecipients = new HashSet();
- String addressList = (getInitParameter("recipients") == null)
- ? getInitParameter("to")
- : getInitParameter("recipients");
- // if nothing was specified, return null meaning no change
- if (addressList == null) {
- return null;
- }
- if(addressList.compareTo("postmaster") == 0) {
- newRecipients.add(getMailetContext().getPostmaster());
- return newRecipients;
- }
- if(addressList.compareTo("sender") == 0) {
- newRecipients.add(SpecialAddress.SENDER);
- return newRecipients;
- }
- StringTokenizer st = new StringTokenizer(addressList, ",", false);
+ public Collection getRecipients() {
+ Collection newRecipients = new HashSet();
+ String addressList = (getInitParameter("recipients") == null)
+ ? getInitParameter("to")
+ : getInitParameter("recipients");
+ StringTokenizer st = new StringTokenizer(addressList, ",", false);
while(st.hasMoreTokens()) {
try {
newRecipients.add(new MailAddress(st.nextToken()));
@@ -495,123 +361,11 @@
}
/**
- * Gets the recipients
init parameter,
- * built dynamically using the original Mail object.
- * Is a "getX(Mail)" method.
- *
- * @return {@link #getRecipients()}, replacing SENDER if applicable
- */
- protected Collection getRecipients(Mail originalMail) throws MessagingException {
- // TODO: implement MailAddress.RETURN_PATH
- Collection recipients = (isStatic()) ? this.recipients : getRecipients();
- if (recipients != null && recipients.size() == 1) {
- if (recipients.contains(SpecialAddress.SENDER)) {
- recipients = new ArrayList();
- recipients.add(originalMail.getSender());
- }
- }
- return recipients;
- }
-
- /**
- * Sets the recipients of newMail to recipients.
- */
- protected void setRecipients(Mail newMail, Collection recipients, Mail originalMail) throws MessagingException {
- if (recipients != null) {
- ((MailImpl) newMail).setRecipients(recipients);
- if (isDebug) {
- log("recipients set to: " + arrayToString(recipients.toArray()));
- }
- }
- }
-
- /**
- * Gets the to
init parameter.
- * Returns the "To:" recipients of the new message.
- * If the to
init parameter is missing,
- * returns the recipients
init parameter.
- * Is a "getX()" method.
- *
- * @return the addresses or SENDER or UNALTERED or null meaning no change
- */
- protected InternetAddress[] getTo() throws MessagingException {
- String addressList = (getInitParameter("to") == null)
- ? getInitParameter("recipients")
- : getInitParameter("to");
- // if nothing was specified, return null meaning no change
- if (addressList == null) {
- return null;
- }
- if(addressList.compareTo("postmaster") == 0) {
- InternetAddress[] iaarray = new InternetAddress[1];
- iaarray[0] = getMailetContext().getPostmaster().toInternetAddress();
- return iaarray;
- }
- if(addressList.compareTo("sender") == 0) {
- InternetAddress[] iaarray = new InternetAddress[1];
- iaarray[0] = SpecialAddress.SENDER.toInternetAddress();
- return iaarray;
- }
- if(addressList.compareTo("unaltered") == 0) {
- InternetAddress[] iaarray = new InternetAddress[1];
- iaarray[0] = SpecialAddress.UNALTERED.toInternetAddress();
- return iaarray;
- }
- StringTokenizer rec = new StringTokenizer(addressList, ",");
- int tokensn = rec.countTokens();
- InternetAddress[] iaarray = new InternetAddress[tokensn];
- String tokenx = "";
- for(int i = 0; i < tokensn; ++i) {
- try {
- tokenx = rec.nextToken();
- iaarray[i] = new InternetAddress(tokenx);
- } catch(Exception e) {
- log("Internet address exception in getTo()");
- }
- }
- return iaarray;
- }
-
- /**
- * Gets the to
init parameter,
- * built dynamically using the original Mail object.
- * Is a "getX(Mail)" method.
- *
- * @return {@link #getTo()}, replacing SENDER and UNALTERED if applicable
- */
- protected InternetAddress[] getTo(Mail originalMail) throws MessagingException {
- InternetAddress[] apparentlyTo = (isStatic()) ? this.apparentlyTo : getTo();
- if (apparentlyTo != null && apparentlyTo.length == 1) {
- if (apparentlyTo[0].equals(SpecialAddress.SENDER.toInternetAddress())) {
- apparentlyTo = new InternetAddress[1];
- apparentlyTo[0] = originalMail.getSender().toInternetAddress();
- } else if (apparentlyTo[0].equals(SpecialAddress.UNALTERED.toInternetAddress())) {
- apparentlyTo = (InternetAddress[]) originalMail.getMessage().getRecipients(Message.RecipientType.TO);
- }
- }
- return apparentlyTo;
- }
-
- /**
- * Sets the "To:" header of newMail to to.
- */
- protected void setTo(Mail newMail, InternetAddress[] to, Mail originalMail) throws MessagingException {
- if (to != null) {
- newMail.getMessage().setRecipients(Message.RecipientType.TO, to);
- if (isDebug) {
- log("apparentlyTo set to: " + arrayToString(to));
- }
- }
- }
-
- /**
- * Gets the replyto
init parameter.
- * Returns the Reply-To address of the new message.
- * Is a "getX()" method.
+ * Returns the reply to address as a string.
*
- * @return an address or null if parameter is missing or == "sender" (null means "use original")
+ * @return the replyto address for the mail as a string
*/
- protected MailAddress getReplyTo() throws MessagingException {
+ public MailAddress getReplyTo() {
String sr = getInitParameter("replyto");
if(sr != null) {
MailAddress rv;
@@ -620,7 +374,6 @@
return rv;
}
if(sr.compareTo("sender") == 0) {
- // means no change
return null;
}
try {
@@ -634,104 +387,9 @@
}
/**
- * Gets the replyTo
init parameter,
- * built dynamically using the original Mail object.
- * Is a "getX(Mail)" method.
- *
- * @return {@link #getReplyTo()}
- */
- protected MailAddress getReplyTo(Mail originalMail) throws MessagingException {
- MailAddress replyTo = (isStatic()) ? this.replyTo : getReplyTo();
- return replyTo;
- }
-
- /**
- * Sets the "Reply-To:" header of newMail to replyTo.
- */
- protected void setReplyTo(Mail newMail, MailAddress replyTo, Mail originalMail) throws MessagingException {
- if(replyTo != null) {
- InternetAddress[] iart = new InternetAddress[1];
- iart[0] = replyTo.toInternetAddress();
- newMail.getMessage().setReplyTo(iart);
- if (isDebug) {
- log("replyTo set to: " + replyTo);
- }
- }
- }
-
- /**
- * Gets the returnPath
init parameter.
- * Returns the Return-Path of the new message.
- * Is a "getX()" method.
- *
- * @return an address or NULL or SENDER or null if parameter is missing (null means "use original")
- */
- protected MailAddress getReturnPath() throws MessagingException {
- String sr = getInitParameter("returnPath");
- if(sr != null) {
- MailAddress rv;
- if(sr.compareTo("postmaster") == 0) {
- return getMailetContext().getPostmaster();
- }
- if(sr.compareTo("NULL") == 0) {
- return SpecialAddress.NULL;
- }
- if(sr.compareTo("sender") == 0) {
- return SpecialAddress.SENDER;
- }
- try {
- rv = new MailAddress(sr);
- return rv;
- } catch(Exception e) {
- log("Parse error in getReturnPath " + sr);
- }
- }
- return null;
- }
-
- /**
- * Gets the returnPath
init parameter,
- * built dynamically using the original Mail object.
- * Is a "getX(Mail)" method.
- *
- * @return {@link #getReturnPath()}, replacing SENDER if applicable, but not replacing NULL
- */
- protected MailAddress getReturnPath(Mail originalMail) throws MessagingException {
- MailAddress returnPath = (isStatic()) ? this.returnPath : getReturnPath();
- if (returnPath != null) {
- if (returnPath == SpecialAddress.SENDER) {
- returnPath = originalMail.getSender();
- }
- }
- return returnPath;
- }
-
- /**
- * Sets the "Return-Path:" header of newMail to returnPath.
- */
- protected void setReturnPath(Mail newMail, MailAddress returnPath, Mail originalMail) throws MessagingException {
- if(returnPath != null) {
- String returnPathString;
- if (returnPath == SpecialAddress.NULL) {
- returnPathString = "";
- } else {
- returnPathString = returnPath.toString();
- }
- newMail.getMessage().setHeader(RFC2822Headers.RETURN_PATH, "<" + returnPathString + ">");
- if (isDebug) {
- log("returnPath set to: " + returnPath);
- }
- }
- }
-
- /**
- * Gets the sender
init parameter.
- * Returns the new sender as a MailAddress.
- * Is a "getX()" method.
- *
- * @return an address or null if parameter is missing or == "sender", meaning "use original"
+ * returns the senders address, as a MailAddress
*/
- protected MailAddress getSender() throws MessagingException {
+ public MailAddress getSender() {
String sr = getInitParameter("sender");
if(sr != null) {
MailAddress rv;
@@ -740,7 +398,6 @@
return rv;
}
if(sr.compareTo("sender") == 0) {
- // means no change: use FROM header; kept as is for compatibility
return null;
}
try {
@@ -754,43 +411,22 @@
}
/**
- * Gets the sender
init parameter,
- * built dynamically using the original Mail object.
- * Is a "getX(Mail)" method.
- *
- * @return {@link #getSender()}
- */
- protected MailAddress getSender(Mail originalMail) throws MessagingException {
- MailAddress sender = (isStatic()) ? this.sender : getSender();
- return sender;
- }
-
- /**
- * Sets the sender and the "From:" header of newMail to sender.
- * If sender is null will set such values to the ones in originalMail.
+ * return true to reduce calls to getTo, getSender, getRecipients, getReplyTo amd getMessage
+ * where these values don't change (eg hard coded, or got at startup from the mailet config)prefix
init parameter.
- * Returns a prefix for the new message subject.
- * Is a "getX()" method.
- *
- * @return the prefix or an empty string if parameter is missing
+ * return a prefix for the message subject
*/
- protected String getSubjectPrefix() throws MessagingException {
+ public String getSubjectPrefix() {
if(getInitParameter("prefix") == null) {
return "";
} else {
@@ -799,41 +435,31 @@
}
/**
- * Gets the subjectPrefix
init parameter,
- * built dynamically using the original Mail object.
- * Is a "getX(Mail)" method.
- *
- * @return {@link #getSubjectPrefix()}
- */
- protected String getSubjectPrefix(Mail originalMail) throws MessagingException {
- String subjectPrefix = (isStatic()) ? this.subjectPrefix : getSubjectPrefix();
- return subjectPrefix;
- }
-
- /**
- * Builds the subject of newMail appending the subject
- * of originalMail to subjectPrefix.
+ * returns an array of InternetAddress 'es for the To: header
*/
- protected void setSubjectPrefix(Mail newMail, String subjectPrefix, Mail originalMail) throws MessagingException {
- String subject = originalMail.getMessage().getSubject();
- if (subject == null) {
- subject = "";
- }
- newMail.getMessage().setSubject(subjectPrefix + subject);
- if (isDebug) {
- log("subjectPrefix set to: " + subjectPrefix);
+ public InternetAddress[] getTo() {
+ String addressList = (getInitParameter("to") == null)
+ ? getInitParameter("recipients") : getInitParameter("to");
+ StringTokenizer rec = new StringTokenizer(addressList, ",");
+ int tokensn = rec.countTokens();
+ InternetAddress[] iaarray = new InternetAddress[tokensn];
+ String tokenx = "";
+ for(int i = 0; i < tokensn; ++i) {
+ try {
+ tokenx = rec.nextToken();
+ iaarray[i] = new InternetAddress(tokenx);
+ } catch(Exception e) {
+ log("Internet address exception in getTo()");
+ }
}
+ return iaarray;
}
-
+
/**
- * Gets the attachError
init parameter.
- * Returns a boolean indicating whether to append a description of any error to the main body part
- * of the new message, if getInlineType does not return "UNALTERED".
- * Is a "getX()" method.
- *
- * @return true or false; false if init parameter missing
+ * return true to append a description of any error to the main body part
+ * if getInlineType does not return "UNALTERED"
*/
- protected boolean attachError() throws MessagingException {
+ public boolean attachError() {
if(getInitParameter("attachError") == null) {
return false;
} else {
@@ -842,101 +468,31 @@
}
/**
- * Gets the attachError
init parameter,
- * built dynamically using the original Mail object.
- * Is a "getX(Mail)" method.
- *
- * @return {@link #attachError()}
- */
- protected boolean attachError(Mail originalMail) throws MessagingException {
- boolean attachError = (isStatic()) ? this.attachError : attachError();
- return attachError;
- }
-
- /**
- * Gets the isReply
init parameter.
- * Returns a boolean indicating whether the new message must be considered
- * a reply to the original message, setting the IN_REPLY_TO header of the new
- * message to the id of the original message.
- * Is a "getX()" method.
- *
- * @return true or false; false if init parameter missing
- */
- protected boolean isReply() throws MessagingException {
- if(getInitParameter("isReply") == null) {
- return false;
- }
- return new Boolean(getInitParameter("isReply")).booleanValue();
- }
-
- /**
- * Gets the isReply
init parameter,
- * built dynamically using the original Mail object.
- * Is a "getX(Mail)" method.
- *
- * @return {@link #isReply()}
- */
- protected boolean isReply(Mail originalMail) throws MessagingException {
- boolean isReply = (isStatic()) ? this.isReply : isReply();
- return isReply;
- }
-
- /**
- * Sets the "In-Reply-To:" header of newMail to the "Message-Id:" of
- * originalMail, if isReply is true.
- */
- protected void setIsReply(Mail newMail, boolean isReply, Mail originalMail) throws MessagingException {
- if (isReply) {
- String messageId = originalMail.getMessage().getMessageID();
- if (messageId != null) {
- newMail.getMessage().setHeader(RFC2822Headers.IN_REPLY_TO, messageId);
- if (isDebug) {
- log("IN_REPLY_TO set to: " + messageId);
- }
- }
- }
- }
-
- /**
- * Mailet initialization routine.
- * Will setup static values for each "x" initialization parameter in config.xml,
- * using getX(), if isStatic() returns true.
- *
- */
+ * init will setup static values for sender, recipients, message text, and reply to
+ *