org.apache.servicemix.mail.utils
Class MailUtils

java.lang.Object
  extended by org.apache.servicemix.mail.utils.MailUtils

public final class MailUtils
extends java.lang.Object

utility class

Author:
lhein

Field Summary
static java.lang.String CONNECTION_TIMEOUT
           
static int DEFAULT_PORT_IMAP
           
static int DEFAULT_PORT_IMAPS
           
static int DEFAULT_PORT_NNTP
           
static int DEFAULT_PORT_POP3
           
static int DEFAULT_PORT_POP3S
           
static int DEFAULT_PORT_SMTP
           
static int DEFAULT_PORT_SMTPS
           
static java.lang.String KEY_BODY_HTML
           
static java.lang.String KEY_BODY_TEXT
           
static java.lang.String PROTOCOL_IMAP
           
static java.lang.String PROTOCOL_IMAPS
           
static java.lang.String PROTOCOL_NNTP
           
static java.lang.String PROTOCOL_POP
           
static java.lang.String PROTOCOL_POP3
           
static java.lang.String PROTOCOL_POP3S
           
static java.lang.String PROTOCOL_SMTP
           
static java.lang.String PROTOCOL_SMTPS
           
static java.lang.String SSL_FACTORY
           
 
Method Summary
static MailConnectionConfiguration configure(java.lang.String uriString)
          parse the connection details via given uri
static void extractAttachmentsFromMail(javax.jbi.messaging.NormalizedMessage nmsg, javax.mail.internet.MimeMessage mailMsg)
          extracts the attachments from the mail
static void extractAttachmentsFromMultipart(javax.mail.Multipart mp, javax.jbi.messaging.NormalizedMessage nmsg)
          extracts attachments from a multipart mail part
static java.lang.Object extractBodyFromMail(javax.mail.Message message)
          Extracts the body from the Mail message
static void extractBodyFromMail(javax.jbi.messaging.NormalizedMessage nmsg, javax.mail.internet.MimeMessage mailMsg)
          extracts the body from the mail
static java.util.Map<java.lang.String,java.lang.String> extractBodyFromMultipart(javax.mail.Multipart mp, javax.jbi.messaging.NormalizedMessage nmsg)
          returns the body of the mail
static void extractHeadersFromMail(javax.jbi.messaging.NormalizedMessage nmsg, javax.mail.internet.MimeMessage mailMsg)
          copy the headers of the mail message into the normalized message headers
static int getDefaultPortForProtocol(java.lang.String protocol)
          returns the default port for a given protocol
static java.util.Properties getPropertiesForProtocol(MailConnectionConfiguration config, java.lang.String customTrustManagers)
          returns the connection properties for use in endpoints
static void parsePart(javax.mail.internet.MimeBodyPart mbp, javax.jbi.messaging.NormalizedMessage nmsg)
          extracts and parses the attachments found in the mail bodies and puts them to the normalized message attachments
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

KEY_BODY_TEXT

public static final java.lang.String KEY_BODY_TEXT
See Also:
Constant Field Values

KEY_BODY_HTML

public static final java.lang.String KEY_BODY_HTML
See Also:
Constant Field Values

SSL_FACTORY

public static final java.lang.String SSL_FACTORY
See Also:
Constant Field Values

DEFAULT_PORT_SMTP

public static final int DEFAULT_PORT_SMTP
See Also:
Constant Field Values

DEFAULT_PORT_SMTPS

public static final int DEFAULT_PORT_SMTPS
See Also:
Constant Field Values

DEFAULT_PORT_POP3

public static final int DEFAULT_PORT_POP3
See Also:
Constant Field Values

DEFAULT_PORT_POP3S

public static final int DEFAULT_PORT_POP3S
See Also:
Constant Field Values

DEFAULT_PORT_NNTP

public static final int DEFAULT_PORT_NNTP
See Also:
Constant Field Values

DEFAULT_PORT_IMAP

public static final int DEFAULT_PORT_IMAP
See Also:
Constant Field Values

DEFAULT_PORT_IMAPS

public static final int DEFAULT_PORT_IMAPS
See Also:
Constant Field Values

PROTOCOL_SMTP

public static final java.lang.String PROTOCOL_SMTP
See Also:
Constant Field Values

PROTOCOL_SMTPS

public static final java.lang.String PROTOCOL_SMTPS
See Also:
Constant Field Values

PROTOCOL_POP

public static final java.lang.String PROTOCOL_POP
See Also:
Constant Field Values

PROTOCOL_POP3

public static final java.lang.String PROTOCOL_POP3
See Also:
Constant Field Values

PROTOCOL_POP3S

public static final java.lang.String PROTOCOL_POP3S
See Also:
Constant Field Values

PROTOCOL_NNTP

public static final java.lang.String PROTOCOL_NNTP
See Also:
Constant Field Values

PROTOCOL_IMAP

public static final java.lang.String PROTOCOL_IMAP
See Also:
Constant Field Values

PROTOCOL_IMAPS

public static final java.lang.String PROTOCOL_IMAPS
See Also:
Constant Field Values

CONNECTION_TIMEOUT

public static final java.lang.String CONNECTION_TIMEOUT
See Also:
Constant Field Values
Method Detail

getDefaultPortForProtocol

public static int getDefaultPortForProtocol(java.lang.String protocol)
returns the default port for a given protocol

Parameters:
protocol - the protocol
Returns:
the default port

configure

public static MailConnectionConfiguration configure(java.lang.String uriString)
                                             throws javax.mail.internet.ParseException
parse the connection details via given uri

Parameters:
uriString - the uri used for connection
Returns:
a mail connection configuration object
Throws:
javax.mail.internet.ParseException - if the uri couldn't be parsed

getPropertiesForProtocol

public static java.util.Properties getPropertiesForProtocol(MailConnectionConfiguration config,
                                                            java.lang.String customTrustManagers)
returns the connection properties for use in endpoints

Parameters:
config - the connection configuration
customTrustManagers - the custom trust manager(s)
Returns:
the connection properties

extractBodyFromMail

public static java.lang.Object extractBodyFromMail(javax.mail.Message message)
Extracts the body from the Mail message

Parameters:
message - the mail message
Returns:
the mail body

extractHeadersFromMail

public static void extractHeadersFromMail(javax.jbi.messaging.NormalizedMessage nmsg,
                                          javax.mail.internet.MimeMessage mailMsg)
                                   throws javax.mail.MessagingException
copy the headers of the mail message into the normalized message headers

Parameters:
nmsg - the message to use
mailMsg - the mail message
Throws:
javax.mail.MessagingException - on any errors

extractAttachmentsFromMultipart

public static void extractAttachmentsFromMultipart(javax.mail.Multipart mp,
                                                   javax.jbi.messaging.NormalizedMessage nmsg)
                                            throws javax.mail.MessagingException,
                                                   javax.jbi.messaging.MessagingException,
                                                   java.io.IOException
extracts attachments from a multipart mail part

Parameters:
mp - the multipart
nmsg - the normalized message
Throws:
javax.mail.MessagingException - on mail errors
javax.jbi.messaging.MessagingException - on jbi messaging errors
java.io.IOException - on io errors

extractBodyFromMultipart

public static java.util.Map<java.lang.String,java.lang.String> extractBodyFromMultipart(javax.mail.Multipart mp,
                                                                                        javax.jbi.messaging.NormalizedMessage nmsg)
                                                                                 throws javax.mail.MessagingException,
                                                                                        java.io.IOException
returns the body of the mail

Parameters:
mp - the multipart
nmsg - the normalized message
Returns:
a map of mail bodies
Throws:
javax.mail.MessagingException - on mail message errors
java.io.IOException - on io errors

parsePart

public static void parsePart(javax.mail.internet.MimeBodyPart mbp,
                             javax.jbi.messaging.NormalizedMessage nmsg)
                      throws javax.jbi.messaging.MessagingException,
                             javax.mail.MessagingException,
                             java.io.IOException
extracts and parses the attachments found in the mail bodies and puts them to the normalized message attachments

Parameters:
mbp - the mime body part to parse
nmsg - the normalized message to fill
Throws:
javax.jbi.messaging.MessagingException - on messaging errors
javax.mail.MessagingException - on mail message errors
java.io.IOException - on io errors

extractBodyFromMail

public static void extractBodyFromMail(javax.jbi.messaging.NormalizedMessage nmsg,
                                       javax.mail.internet.MimeMessage mailMsg)
                                throws javax.mail.MessagingException,
                                       javax.jbi.messaging.MessagingException
extracts the body from the mail

Parameters:
nmsg - the normalized message
mailMsg - the mail message
Throws:
javax.jbi.messaging.MessagingException - on messaging errors
javax.mail.MessagingException - on mail message errors

extractAttachmentsFromMail

public static void extractAttachmentsFromMail(javax.jbi.messaging.NormalizedMessage nmsg,
                                              javax.mail.internet.MimeMessage mailMsg)
extracts the attachments from the mail

Parameters:
nmsg - the normalized message
mailMsg - the mail message


Copyright © 2005-2012 FuseSource. All Rights Reserved.