Class MessageUtil

java.lang.Object
com.jalios.jcms.mail.MessageUtil

public class MessageUtil extends Object
  • Method Details

    • logMessages

      public static void logMessages(MailMessage msg)
      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

      public static void logMessages(MailMessage[] msgs)
      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 - the MailMessage
      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 - the MailMessage
      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

      public static TreeSet<String> getToRecipientSet(Collection<MailMessage> messages)
      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

      public static String getMessageIdQuietly(javax.mail.Message msg)
      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

      public static File writeEml(javax.mail.Message msg)
      Write a Message to a file
      Parameters:
      msg - the Message
      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.MessagingException
      IOException