Class MailUtils

java.lang.Object
org.apache.camel.component.mail.MailUtils

public final class MailUtils extends Object
Mail utility class.

Parts of the code copied from Apache ServiceMix.

  • Field Details

  • Method Details

    • getDefaultPortForProtocol

      public static int getDefaultPortForProtocol(String protocol)
      Returns the default port for a given protocol.

      If a protocol could not successfully be determined the default port number for SMTP protocol is returned.

      Parameters:
      protocol - the protocol
      Returns:
      the default port
    • dumpMessage

      public static String dumpMessage(jakarta.mail.Message message)
      Gets a log dump of the given message that can be used for tracing etc.
      Parameters:
      message - the Mail message
      Returns:
      a log string with important fields dumped
    • padContentType

      public static String padContentType(String contentType)
      Pads the content-type so it has a space after semi colon that separate pairs.

      This is needed as some mail servers will choke otherwise

      Parameters:
      contentType - the content type
      Returns:
      the padded content type
    • replaceCharSet

      public static String replaceCharSet(String contentType, String charset)
      Replaces the charset in the content-type
      Parameters:
      contentType - the content-type
      charset - the charset to replace, can be null to remove charset
      Returns:
      the content-type with replaced charset
    • getCharSetFromContentType

      public static String getCharSetFromContentType(String contentType)
      Gets the charset from the content-type
      Parameters:
      contentType - the content-type
      Returns:
      the charset, or null if no charset existed