Package com.jalios.jcms.mail
Class MessageUtil
java.lang.Object
com.jalios.jcms.mail.MessageUtil
-
Method Summary
Modifier and TypeMethodDescriptionprotected static voidaddHeaders(MailMessage mailMessage, javax.mail.Message message) static javax.mail.MessagebuildMessage(MailMessage mailMessage) Build a MimeMessage bodyPartEncoding values are: text/plain; charset=UTF-8 | text/html; charset=UTF-8static MailMessage[]buildOneMessageForEach(MailMessage mailMessage) Create one message one for each recipients.static Collection<MailMessage.Part> decodeMultipart(javax.mail.Message msg) protected static voidfillMessageContent(MailMessage mailMessage, javax.mail.Message message) static StringgetMessageIdQuietly(javax.mail.Message msg) Returns the messageId for the given message.getToRecipientSet(Collection<MailMessage> messages) Utility method which create a TreeSet of all to recipients email from the specified messages.static voidlogMessages(MailMessage msg) This method is used to log them using log4j (for example when mail is disabled).static voidlogMessages(MailMessage[] msgs) This method is used to log them using log4j (for example when mail is disabled).static FilewriteEml(javax.mail.Message msg) Write aMessageto a file
-
Method Details
-
logMessages
This method is used to log them using log4j (for example when mail is disabled).- Parameters:
msg- the message that should have been sent.
-
logMessages
This method is used to log them using log4j (for example when mail is disabled).- Parameters:
msgs- the message array that will be logged.
-
buildMessage
public static javax.mail.Message buildMessage(MailMessage mailMessage) throws javax.mail.MessagingException Build a MimeMessage bodyPartEncoding values are: text/plain; charset=UTF-8 | text/html; charset=UTF-8- Parameters:
mailMessage- theMailMessage- Returns:
- a new Message instance
- Throws:
javax.mail.MessagingException- When including attachments with your messages, if your program is a servlet, your users must upload the attachment besides tell you where to send the message. Uploading each file can be handled with a form encoding type of multipart/form-data.
-
buildOneMessageForEach
public static MailMessage[] buildOneMessageForEach(MailMessage mailMessage) throws javax.mail.MessagingException Create one message one for each recipients.- Parameters:
mailMessage- theMailMessage- Returns:
- the message
- Throws:
javax.mail.MessagingException- if an error occurs
-
addHeaders
protected static void addHeaders(MailMessage mailMessage, javax.mail.Message message) throws javax.mail.MessagingException - Throws:
javax.mail.MessagingException
-
fillMessageContent
protected static void fillMessageContent(MailMessage mailMessage, javax.mail.Message message) throws javax.mail.MessagingException - Throws:
javax.mail.MessagingException
-
getToRecipientSet
Utility method which create a TreeSet of all to recipients email from the specified messages.- Parameters:
messages- the message in which to retrieve recipients- Returns:
- a Set of email, never return null.
- Since:
- jcms-10.0.5
-
getMessageIdQuietly
Returns the messageId for the given message. Trying to catch and log messaging exception.- Parameters:
msg- the javax.mail.Message- Returns:
- String the message Id or null
-
writeEml
Write aMessageto a file- Parameters:
msg- theMessage- Returns:
- the File with the message saved in
-
decodeMultipart
public static Collection<MailMessage.Part> decodeMultipart(javax.mail.Message msg) throws javax.mail.MessagingException, IOException - Throws:
javax.mail.MessagingExceptionIOException
-