Package com.iplanet.am.util
Class AMSendMail
- java.lang.Object
-
- com.iplanet.am.util.AMSendMail
-
public class AMSendMail extends Object
-
-
Constructor Summary
Constructors Constructor Description AMSendMail()Constructor that grabs its SMTP values from SystemProperties.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidpostMail(String[] recipients, String subject, String message, String from)Posts e-mail messages to users.voidpostMail(String[] recipients, String subject, String message, String from, String charset)Posts e-mail messages to users.voidpostMail(String[] recipients, String subject, String message, String from, String mimeType, String charset)Posts e-mail messages to users.voidpostMail(String[] recipients, String subject, String message, String from, String charset, String host, String port, String user, String password, boolean ssl)Posts e-mail messages to users.voidpostMail(String[] recipients, String subject, String message, String from, String mimeType, String charset, String host, String port, String user, String password, boolean ssl)Posts e-mail messages to users.static StringsanitizeHeaderValue(String value)Replaces the control characters of an e-mail header value with spaces, the tab excepted.
-
-
-
Method Detail
-
sanitizeHeaderValue
public static String sanitizeHeaderValue(String value)
Replaces the control characters of an e-mail header value with spaces, the tab excepted. An RFC 5322 header is a single logical line, so a CR or an LF left in a value ends the header and lets everything after it be read as a header of its own - a Bcc, a Reply-To or, with an empty line, the message body. Jakarta Mail folds the Subject of such a value into a continuation line instead, but only while the default mail.mime.foldtext setting is in force, and it does not fold the Content-Type at all: a CR or an LF inside a quoted parameter of it is written out as it came. An address is no safer: the quoted display name of one carries a break through the parser untouched. The characters are therefore taken out here rather than relying on the library. The other control characters go the same way. They do not end a header, but a NUL truncates the header block at some agents, which comes to the same thing. A mail server implementation of its own, plugged in through forgerockMailServerImplClassName, does not go through this class; it is public so that such an implementation can sanitise the values it sets itself.- Parameters:
value- The header value to sanitise, may be null- Returns:
- The value with every control character other than the tab replaced by a space, or null if the value was null
-
postMail
public void postMail(String[] recipients, String subject, String message, String from, String charset) throws jakarta.mail.MessagingException
Posts e-mail messages to users. This method will wait on for the timeouts when the specified host is down. Use this method in a separate thread so that it will not hang when the mail server is down.- Parameters:
recipients- A String array of e-mail addresses to be sent tosubject- The e-mail subjectmessage- The content contained in the e-mailfrom- The sending e-mail addresscharset- The charset used in e-mail encoding- Throws:
jakarta.mail.MessagingException- if there is any error in sending e-mail
-
postMail
public void postMail(String[] recipients, String subject, String message, String from) throws jakarta.mail.MessagingException
Posts e-mail messages to users. This method will wait on for the timeouts when the specified host is down. Use this method in a separate thread so that it will not hang when the mail server is down.- Parameters:
recipients- A String array of e-mail addresses to be sent tosubject- The e-mail subjectmessage- The content contained in the e-mailfrom- The sending e-mail address- Throws:
jakarta.mail.MessagingException- if there is any error in sending e-mail
-
postMail
public void postMail(String[] recipients, String subject, String message, String from, String mimeType, String charset) throws jakarta.mail.MessagingException
Posts e-mail messages to users. This method will wait on for the timeouts when the specified host is down. Use this method in a separate thread so that it will not hang when the mail server is down.- Parameters:
recipients- A String array of e-mail addresses to be sent tosubject- The e-mail subjectmessage- The content contained in the e-mailfrom- The sending e-mail addressmimeType- The MIME type of the e-mailcharset- The charset used in e-mail encoding- Throws:
jakarta.mail.MessagingException- if there is any error in sending e-mail
-
postMail
public void postMail(String[] recipients, String subject, String message, String from, String charset, String host, String port, String user, String password, boolean ssl) throws jakarta.mail.MessagingException
Posts e-mail messages to users. This method will wait on for the timeouts when the specified host is down. Use this method in a separate thread so that it will not hang when the mail server is down.- Parameters:
recipients- A String array of e-mail addresses to be sent tosubject- The e-mail subjectmessage- The content contained in the e-mailfrom- The sending e-mail addresscharset- The charset used in e-mail encodinghost- The host name to connect to send e-mailport- The host port to connect to send e-mailuser- The user name used to authenticate to the hostpassword- The user password used to authenticate to the hostssl- A boolean to indicate whether SSL is needed to connect to the host- Throws:
jakarta.mail.MessagingException- if there is any error in sending e-mail
-
postMail
public void postMail(String[] recipients, String subject, String message, String from, String mimeType, String charset, String host, String port, String user, String password, boolean ssl) throws jakarta.mail.MessagingException
Posts e-mail messages to users. This method will wait on for the timeouts when the specified host is down. Use this method in a separate thread so that it will not hang when the mail server is down.- Parameters:
recipients- A String array of e-mail addresses to be sent tosubject- The e-mail subjectmessage- The content contained in the e-mailfrom- The sending e-mail addressmimeType- The MIME type of the e-mailcharset- The charset used in e-mail encodinghost- The host name to connect to send e-mailport- The host port to connect to send e-mailuser- The user name used to authenticate to the hostpassword- The user password used to authenticate to the hostssl- A boolean to indicate whether SSL is needed to connect to the host- Throws:
jakarta.mail.MessagingException- if there is any error in sending e-mail
-
-