public final class MailUtil
extends java.lang.Object
sendMail(...)
methods send one and only one mail for all recipients.sendMails(...)
methods send one mail per recipient (spliting the recipients on comma).sendMessage(...)
methods send one mail per given Message.Modifier and Type | Field and Description |
---|---|
static java.lang.String[] |
BODYPART_ENCODINGS
Predefined array of body part encoding.
|
static java.lang.String |
BODYPART_TEXT_HTML_ENCODING |
static java.lang.String |
BODYPART_TEXT_PLAIN_ENCODING |
protected static boolean |
enabled |
static int |
PRIORITY_HIGH |
static int |
PRIORITY_HIGHEST |
static int |
PRIORITY_LOW |
static int |
PRIORITY_LOWEST |
static int |
PRIORITY_NORMAL |
protected static java.util.Properties |
props |
static java.lang.String |
REVISION |
protected static javax.mail.Session |
session |
Modifier and Type | Method and Description |
---|---|
static javax.mail.Message |
buildMessage(java.lang.String from,
java.lang.String recipients,
java.lang.String copies,
java.lang.String bcopies,
java.lang.String subject,
java.lang.String[] bodyPart,
java.lang.String[] bodyPartEncoding,
java.util.Map<java.io.File,java.lang.String> files,
int priority)
Build a MimeMessage
bodyPartEncoding values are: text/plain; charset=UTF-8 | text/html; charset=UTF-8
|
static javax.mail.Message |
buildMessage(java.lang.String from,
java.lang.String recipients,
java.lang.String copies,
java.lang.String bcopies,
java.lang.String subject,
java.lang.String[] bodyPart,
java.lang.String[] bodyPartEncoding,
java.util.Map<java.io.File,java.lang.String> files,
int priority,
javax.mail.BodyPart[] bodyPartObjects)
Build a MimeMessage
bodyPartEncoding values are: text/plain; charset=UTF-8 | text/html; charset=UTF-8
|
static boolean |
checkEmail(java.lang.String email)
Checks that the given string has a valid email syntax.
|
static void |
configure(java.lang.String host,
java.lang.String port,
java.lang.String login,
java.lang.String password,
java.util.Properties addedProps)
Configure MailUtil properties (of javax.mail.Session) using the given values.
|
static void |
disable()
Disable MailUtil, that is all call to methods of MailUtil will results
in log message and no mail is ever send.
|
static java.util.Set<java.lang.String> |
emailsStringToEmailSet(java.lang.String emails)
Retrieve a Set of emails from a string of coma separated emails
|
static void |
enable()
Enable MailUtil, that is all call to methods of MailUtil will send
mail using the configuration given during call to
configure(String, String, String, String, Properties) . |
static java.lang.String |
getBeautifiedEmail(java.lang.String email)
Convert a text email to an HTML representation.
|
static java.lang.String |
getBeautifiedEmail(java.lang.String email,
boolean isColored)
Convert a text email to an HTML representation.
|
static java.lang.String |
getBeautifiedEmail(java.lang.String email,
java.lang.String css1,
java.lang.String css2,
boolean isColored)
Convert a text email to an HTML representation.
|
static java.lang.String |
getCanonizedEmail(java.lang.String email)
Canonizes an email.
|
static java.lang.String |
getCharset(java.lang.String contentType)
Returns charset for the given mail contentType
|
static javax.mail.internet.InternetAddress |
getIA(java.lang.String email)
Retrieve a new InternetAddress instance (with properly encoded personnal).
|
static java.util.Set<javax.mail.internet.InternetAddress> |
getIAFromMailSet(java.util.Set<java.lang.String> mailSet)
Returns a Set of InternetAddress from a Set of mail String
|
static javax.mail.internet.InternetAddress |
getIAQuietly(java.lang.String address)
Returns an InternetAddress object from the specified email ddress
|
static javax.mail.internet.InternetAddress |
getInternetAddress(java.lang.String email)
Retrieve a new InternetAddress instance (with properly encoded personnal).
|
static java.util.TreeSet<java.lang.String> |
getRecipientSet(java.util.Collection<javax.mail.Message> messages,
javax.mail.Message.RecipientType type)
Utility method which create a TreeSet of all recipients email from the specified messages.
|
static javax.mail.Session |
getSession()
Retrieve the sesssion being used to send mails.
|
static boolean |
hasRecipient(javax.mail.Message message)
Check if the specified message has recipient.
|
static java.lang.String |
logAddress(javax.mail.Address[] address) |
static java.lang.String |
logFlags(javax.mail.Flags.Flag[] flags) |
static java.lang.String |
logHeaders(javax.mail.Message msg) |
static java.lang.String |
logMessage(javax.mail.Message msg) |
static void |
sendMail(java.lang.String from,
java.lang.String recipients,
java.lang.String subject,
java.lang.String bodyText)
Send 1 Mail to all the given recipients.
|
static void |
sendMail(java.lang.String from,
java.lang.String recipients,
java.lang.String subject,
java.lang.String bodyText,
java.util.Map<java.io.File,java.lang.String> files,
int priority)
Send 1 Mail to all the given recipients.
|
static void |
sendMail(java.lang.String from,
java.lang.String recipients,
java.lang.String copies,
java.lang.String bcopies,
java.lang.String subject,
java.lang.String[] bodyPart,
java.lang.String[] bodyPartEncoding,
java.util.Map<java.io.File,java.lang.String> files,
int priority,
javax.mail.BodyPart[] bodyPartObjects,
java.lang.String host,
int port,
java.lang.String login,
java.lang.String password)
Send 1 Mail to all the given recipients.
|
static void |
sendMail(java.lang.String from,
java.lang.String recipients,
java.lang.String copies,
java.lang.String bcopies,
java.lang.String subject,
java.lang.String[] bodyPart,
java.lang.String[] bodyPartEncoding,
java.util.Map<java.io.File,java.lang.String> files,
int priority,
java.lang.String host,
int port,
java.lang.String login,
java.lang.String password)
Send 1 Mail to all the given recipients.
|
static void |
sendMail(java.lang.String from,
java.lang.String recipients,
java.lang.String copies,
java.lang.String bcopies,
java.lang.String subject,
java.lang.String bodyText,
java.util.Map<java.io.File,java.lang.String> files,
int priority)
Send 1 Mail to all the given recipients.
|
static void |
sendMail(java.lang.String from,
java.lang.String recipients,
java.lang.String copies,
java.lang.String bcopies,
java.lang.String subject,
java.lang.String bodyText,
java.util.Map<java.io.File,java.lang.String> files,
int priority,
java.lang.String host,
int port,
java.lang.String login,
java.lang.String password)
Send 1 Mail to all the given recipients.
|
static java.util.List<java.lang.String> |
sendMails(java.lang.String from,
java.lang.String recipients,
java.lang.String subject,
java.lang.String bodyText)
Send 1 mail for each given recipients.
|
static java.util.List<java.lang.String> |
sendMails(java.lang.String from,
java.lang.String recipients,
java.lang.String subject,
java.lang.String bodyText,
java.util.Map<java.io.File,java.lang.String> files,
int priority)
Send 1 mail for each given recipients.
|
static java.util.List<java.lang.String> |
sendMails(java.lang.String from,
java.lang.String recipients,
java.lang.String copies,
java.lang.String bcopies,
java.lang.String subject,
java.lang.String[] bodyPart,
java.lang.String[] bodyPartEncoding,
java.util.Map<java.io.File,java.lang.String> files,
int priority,
javax.mail.BodyPart[] bodyPartObjects,
java.lang.String host,
int port,
java.lang.String login,
java.lang.String password)
Send n Mails.
|
static java.util.List<java.lang.String> |
sendMails(java.lang.String from,
java.lang.String recipients,
java.lang.String copies,
java.lang.String bcopies,
java.lang.String subject,
java.lang.String[] bodyPart,
java.lang.String[] bodyPartEncoding,
java.util.Map<java.io.File,java.lang.String> files,
int priority,
java.lang.String host,
int port,
java.lang.String login,
java.lang.String password)
Send n Mails.
|
static java.util.List<java.lang.String> |
sendMails(java.lang.String from,
java.lang.String recipients,
java.lang.String copies,
java.lang.String bcopies,
java.lang.String subject,
java.lang.String bodyText,
java.util.Map<java.io.File,java.lang.String> files,
int priority)
Send n Mails.
|
static java.util.List<java.lang.String> |
sendMails(java.lang.String from,
java.lang.String recipients,
java.lang.String copies,
java.lang.String bcopies,
java.lang.String subject,
java.lang.String bodyText,
java.util.Map<java.io.File,java.lang.String> files,
int priority,
java.lang.String host,
int port,
java.lang.String login,
java.lang.String password)
Send n Mails.
|
static java.util.List<javax.mail.Message> |
sendMessage(javax.mail.Message msg,
boolean catchMailErrors)
Send given message.
|
static java.util.List<javax.mail.Message> |
sendMessage(javax.mail.Message msg,
java.lang.String host,
int port,
java.lang.String login,
java.lang.String password,
boolean catchMailErrors)
Send the given message with the given smtp parameters.
|
static java.util.List<javax.mail.Message> |
sendMessages(javax.mail.Message[] msg,
boolean catchMailErrors)
Send given messages.
|
static java.util.List<javax.mail.Message> |
sendMessages(javax.mail.Message[] msg,
java.lang.String host,
int port,
java.lang.String login,
java.lang.String password,
boolean catchMailErrors)
Send given messages.
|
static java.lang.String |
stripQuoteReplies(java.lang.String message,
java.lang.String separator,
java.lang.String reply)
Strip message to wrap inline quotation by [quote] and remove other quotes and signatures
|
static java.lang.String |
toggleReplies(java.lang.String message,
java.lang.String quote,
java.lang.String label)
Strip message to show/hide quotation using javascript and css.
|
public static final java.lang.String REVISION
public static final java.lang.String BODYPART_TEXT_PLAIN_ENCODING
public static final java.lang.String BODYPART_TEXT_HTML_ENCODING
public static final int PRIORITY_HIGHEST
public static final int PRIORITY_HIGH
public static final int PRIORITY_NORMAL
public static final int PRIORITY_LOW
public static final int PRIORITY_LOWEST
public static final java.lang.String[] BODYPART_ENCODINGS
MailUtil.BODYPART_TEXT_PLAIN_ENCODING
. MailUtil.BODYPART_TEXT_HTML_ENCODING
.protected static final java.util.Properties props
protected static final javax.mail.Session session
protected static boolean enabled
public static void configure(java.lang.String host, java.lang.String port, java.lang.String login, java.lang.String password, java.util.Properties addedProps)
host
- host of the SMTP serverport
- port of the SMTP serverlogin
- login used to connect to the SMTP serverpassword
- password used to connect to the SMTP serveraddedProps
- more properties that will be added to javax.mail.Session properties if not null.public static void enable()
configure(String, String, String, String, Properties)
.public static void disable()
public static javax.mail.Session getSession()
public static java.util.Set<javax.mail.internet.InternetAddress> getIAFromMailSet(java.util.Set<java.lang.String> mailSet) throws javax.mail.MessagingException
mailSet
- Set of mail Stringjavax.mail.MessagingException
public static javax.mail.internet.InternetAddress getIAQuietly(java.lang.String address)
address
- the email address. (eg: "John Smith" <john.smith@example.com>)public static javax.mail.internet.InternetAddress getIA(java.lang.String email) throws javax.mail.internet.AddressException
email
- the email address. (eg: "John Smith" <john.smith@example.com>)javax.mail.internet.AddressException
- if the email address could not be parsed.public static javax.mail.internet.InternetAddress getInternetAddress(java.lang.String email) throws javax.mail.internet.AddressException
email
- the email address. (eg: "John Smith" <john.smith@example.com>)javax.mail.internet.AddressException
- if the email address could not be parsed.public static boolean checkEmail(java.lang.String email)
email
- the email to be checkedpublic static java.lang.String getCanonizedEmail(java.lang.String email)
olivier.dedieu@inria.fr
for Olivier Dedieu
<olivier.dedieu@inria.fr>
email
- the email to be canonizedpublic static java.util.TreeSet<java.lang.String> getRecipientSet(java.util.Collection<javax.mail.Message> messages, javax.mail.Message.RecipientType type)
messages
- the message in which to retrieve recipientstype
- the type of recipient to find, if null, all recipient are usedpublic static java.util.Set<java.lang.String> emailsStringToEmailSet(java.lang.String emails)
emails
- a string containing one or several mail addresses seperated with coma,
e.g "Foo Bar" <foobar@company.com>, "John Smith" <js@company.com>
public static java.lang.String getCharset(java.lang.String contentType)
contentType
- the contentType headerpublic static java.lang.String getBeautifiedEmail(java.lang.String email)
email
- the email String representationpublic static java.lang.String getBeautifiedEmail(java.lang.String email, boolean isColored)
email
- the email String representationisColored
- will set a colorpublic static java.lang.String getBeautifiedEmail(java.lang.String email, java.lang.String css1, java.lang.String css2, boolean isColored)
email
- the email String representationcss1
- the first css to applycss2
- the second css to applyisColored
- will set a colorpublic static java.lang.String toggleReplies(java.lang.String message, java.lang.String quote, java.lang.String label)
message
- the text messagequote
- the line startslabel
- the link labelpublic static java.lang.String stripQuoteReplies(java.lang.String message, java.lang.String separator, java.lang.String reply)
message
- the text messageseparator
- the line separator of signaturereply
- a string to identify begining of reply (can be null)public static boolean hasRecipient(javax.mail.Message message)
message
- the message to checkpublic static void sendMail(java.lang.String from, java.lang.String recipients, java.lang.String subject, java.lang.String bodyText) throws javax.mail.NoSuchProviderException, javax.mail.MessagingException
from
- the address senderrecipients
- the list of recipients separated by a commasubject
- the subject of the mailbodyText
- the body of the mail (plain text)javax.mail.NoSuchProviderException
- if no SMTP provider (Transport) could be createdjavax.mail.MessagingException
public static void sendMail(java.lang.String from, java.lang.String recipients, java.lang.String subject, java.lang.String bodyText, java.util.Map<java.io.File,java.lang.String> files, int priority) throws javax.mail.NoSuchProviderException, javax.mail.MessagingException
from
- the address senderrecipients
- the list of recipients separated by a commasubject
- the subject of the mailbodyText
- the body of the mail (plain text)files
- a Map containing files to be attached to the mail. File as the key and an optionnal
String identifier as the value (value is optionnal, if left null, an id is automatically generated from the file name)priority
- priority of the mail to be sent, cf MailUtil.PRIORITY_*, ignored if 0 or any invalid value.javax.mail.NoSuchProviderException
- if no SMTP provider (Transport) could be createdjavax.mail.MessagingException
public static void sendMail(java.lang.String from, java.lang.String recipients, java.lang.String copies, java.lang.String bcopies, java.lang.String subject, java.lang.String bodyText, java.util.Map<java.io.File,java.lang.String> files, int priority) throws javax.mail.NoSuchProviderException, javax.mail.MessagingException
from
- the address senderrecipients
- the list of recipients separated by a commacopies
- the list of recipients in carbon copy separated by a commabcopies
- the list of recipients in blind carbon copy separated by a commasubject
- the subject of the mailbodyText
- the body of the mail (plain text)files
- a Map containing files to be attached to the mail. File as the key and an optionnal
String identifier as the value (value is optionnal, if left null, an id is automatically generated from the file name)priority
- priority of the mail to be sent, cf MailUtil.PRIORITY_*, ignored if 0 or any invalid value.javax.mail.NoSuchProviderException
- if no SMTP provider (Transport) could be createdjavax.mail.MessagingException
public static void sendMail(java.lang.String from, java.lang.String recipients, java.lang.String copies, java.lang.String bcopies, java.lang.String subject, java.lang.String bodyText, java.util.Map<java.io.File,java.lang.String> files, int priority, java.lang.String host, int port, java.lang.String login, java.lang.String password) throws javax.mail.NoSuchProviderException, javax.mail.MessagingException
from
- the address senderrecipients
- the list of recipients separated by a commacopies
- the list of recipients in carbon copy separated by a commabcopies
- the list of recipients in blind carbon copy separated by a commasubject
- the subject of the mailbodyText
- the body of the mail (plain text)files
- a Map containing files to be attached to the mail. File as the key and an optionnal
String identifier as the value (value is optionnal, if left null, an id is automatically generated from the file name)priority
- priority of the mail to be sent, cf MailUtil.PRIORITY_*, ignored if 0 or any invalid value.host
- smtp server host (null means default smtp)port
- smtp server port (<= 0 means default port)login
- login to smtp server (null means default login)password
- password to smtp server (null means default password)javax.mail.NoSuchProviderException
- if no SMTP provider (Transport) could be createdjavax.mail.MessagingException
public static void sendMail(java.lang.String from, java.lang.String recipients, java.lang.String copies, java.lang.String bcopies, java.lang.String subject, java.lang.String[] bodyPart, java.lang.String[] bodyPartEncoding, java.util.Map<java.io.File,java.lang.String> files, int priority, java.lang.String host, int port, java.lang.String login, java.lang.String password) throws javax.mail.NoSuchProviderException, javax.mail.MessagingException
from
- the address senderrecipients
- the list of recipients separated by a commacopies
- the list of recipients in carbon copy separated by a commabcopies
- the list of recipients in blind carbon copy separated by a commasubject
- the subject of the mailbodyPart
- the body parts to be included in the mail (text, html.. etc)bodyPartEncoding
- the encodings associated to each body part (must be present for body part to be used)files
- a Map containing files to be attached to the mail. File as the key and an optionnal
String identifier as the value (value is optionnal, if left null, an id is automatically generated from the file name)priority
- priority of the mail to be sent, cf MailUtil.PRIORITY_*, ignored if 0 or any invalid value.host
- smtp server host (null means default smtp)port
- smtp server port (<= 0 means default port)login
- login to smtp server (null means default login)password
- password to smtp server (null means default password)javax.mail.NoSuchProviderException
- if no SMTP provider (Transport) could be createdjavax.mail.MessagingException
public static void sendMail(java.lang.String from, java.lang.String recipients, java.lang.String copies, java.lang.String bcopies, java.lang.String subject, java.lang.String[] bodyPart, java.lang.String[] bodyPartEncoding, java.util.Map<java.io.File,java.lang.String> files, int priority, javax.mail.BodyPart[] bodyPartObjects, java.lang.String host, int port, java.lang.String login, java.lang.String password) throws javax.mail.NoSuchProviderException, javax.mail.MessagingException
from
- the address senderrecipients
- the list of recipients separated by a commacopies
- the list of recipients in carbon copy separated by a commabcopies
- the list of recipients in blind carbon copy separated by a commasubject
- the subject of the mailbodyPart
- the body parts to be included in the mail (text, html.. etc)bodyPartEncoding
- the encodings associated to each body part (must be present for body part to be used)files
- a Map containing files to be attached to the mail. File as the key and an optionnal
String identifier as the value (value is optionnal, if left null, an id is automatically generated from the file name)priority
- priority of the mail to be sent, cf MailUtil.PRIORITY_*, ignored if 0 or any invalid value.bodyPartObjects
- array of BodyPart
to included in the mailhost
- smtp server host (null means default smtp)port
- smtp server port (<= 0 means default port)login
- login to smtp server (null means default login)password
- password to smtp server (null means default password)javax.mail.NoSuchProviderException
- if no SMTP provider (Transport) could be createdjavax.mail.MessagingException
public static java.util.List<java.lang.String> sendMails(java.lang.String from, java.lang.String recipients, java.lang.String subject, java.lang.String bodyText)
from
- the address senderrecipients
- the list of recipients separated by a commasubject
- the subject of the mailbodyText
- the body of the mail (plain text)public static java.util.List<java.lang.String> sendMails(java.lang.String from, java.lang.String recipients, java.lang.String subject, java.lang.String bodyText, java.util.Map<java.io.File,java.lang.String> files, int priority)
from
- the address senderrecipients
- the list of recipients separated by a commasubject
- the subject of the mailbodyText
- the body of the mail (plain text)files
- a Map containing files to be attached to the mail. File as the key and an optionnal
String identifier as the value (value is optionnal, if left null, an id is automatically generated from the file name)priority
- priority of the mail to be sent, cf MailUtil.PRIORITY_*, ignored if 0 or any invalid value.public static java.util.List<java.lang.String> sendMails(java.lang.String from, java.lang.String recipients, java.lang.String copies, java.lang.String bcopies, java.lang.String subject, java.lang.String bodyText, java.util.Map<java.io.File,java.lang.String> files, int priority)
from
- the address senderrecipients
- the list of recipients separated by a commacopies
- the list of recipients in carbon copy separated by a commabcopies
- the list of recipients in blind carbon copy separated by a commasubject
- the subject of the mailbodyText
- the body of the mail (plain text)files
- a Map containing files to be attached to the mail. File as the key and an optionnal
String identifier as the value (value is optionnal, if left null, an id is automatically generated from the file name)priority
- priority of the mail to be sent, cf MailUtil.PRIORITY_*, ignored if 0 or any invalid value.public static java.util.List<java.lang.String> sendMails(java.lang.String from, java.lang.String recipients, java.lang.String copies, java.lang.String bcopies, java.lang.String subject, java.lang.String bodyText, java.util.Map<java.io.File,java.lang.String> files, int priority, java.lang.String host, int port, java.lang.String login, java.lang.String password)
from
- the address senderrecipients
- the list of recipients separated by a commacopies
- the list of recipients in carbon copy separated by a commabcopies
- the list of recipients in blind carbon copy separated by a commasubject
- the subject of the mailbodyText
- the body of the mail (plain text)files
- a Map containing files to be attached to the mail. File as the key and an optionnal
String identifier as the value (value is optionnal, if left null, an id is automatically generated from the file name)priority
- priority of the mail to be sent, cf MailUtil.PRIORITY_*, ignored if 0 or any invalid value.host
- not usedport
- not usedlogin
- not usedpassword
- not usedpublic static java.util.List<java.lang.String> sendMails(java.lang.String from, java.lang.String recipients, java.lang.String copies, java.lang.String bcopies, java.lang.String subject, java.lang.String[] bodyPart, java.lang.String[] bodyPartEncoding, java.util.Map<java.io.File,java.lang.String> files, int priority, java.lang.String host, int port, java.lang.String login, java.lang.String password)
from
- the address senderrecipients
- the list of recipients separated by a commacopies
- the list of recipients in carbon copy separated by a commabcopies
- the list of recipients in blind carbon copy separated by a commasubject
- the subject of the mailbodyPart
- the body parts to be included in the mail (text, html.. etc)bodyPartEncoding
- the encodings associated to each body part (must be present for body part to be used)files
- a Map containing files to be attached to the mail. File as the key and an optionnal
String identifier as the value (value is optionnal, if left null, an id is automatically generated from the file name)priority
- priority of the mail to be sent, cf MailUtil.PRIORITY_*, ignored if 0 or any invalid value.host
- not usedport
- not usedlogin
- not usedpassword
- not usedpublic static java.util.List<java.lang.String> sendMails(java.lang.String from, java.lang.String recipients, java.lang.String copies, java.lang.String bcopies, java.lang.String subject, java.lang.String[] bodyPart, java.lang.String[] bodyPartEncoding, java.util.Map<java.io.File,java.lang.String> files, int priority, javax.mail.BodyPart[] bodyPartObjects, java.lang.String host, int port, java.lang.String login, java.lang.String password)
from
- the address senderrecipients
- the list of recipients separated by a commacopies
- the list of recipients in carbon copy separated by a commabcopies
- the list of recipients in blind carbon copy separated by a commasubject
- the subject of the mailbodyPart
- the body parts to be included in the mail (text, html.. etc)bodyPartEncoding
- the encodings associated to each body part (must be present for body part to be used)files
- a Map containing files to be attached to the mail. File as the key and an optionnal
String identifier as the value (value is optionnal, if left null, an id is automatically generated from the file name)priority
- priority of the mail to be sent, cf MailUtil.PRIORITY_*, ignored if 0 or any invalid value.bodyPartObjects
- array of BodyPart
to included in the mailhost
- not usedport
- not usedlogin
- not usedpassword
- not usedpublic static java.util.List<javax.mail.Message> sendMessage(javax.mail.Message msg, boolean catchMailErrors) throws javax.mail.NoSuchProviderException, javax.mail.MessagingException
msg
- Message to be sentcatchMailErrors
- set to true to prevent this method to throw exception when sending messagesjavax.mail.NoSuchProviderException
- if no SMTP provider (Transport) could be createdjavax.mail.MessagingException
public static java.util.List<javax.mail.Message> sendMessages(javax.mail.Message[] msg, boolean catchMailErrors) throws javax.mail.NoSuchProviderException, javax.mail.MessagingException
msg
- array of Message to be sentcatchMailErrors
- set to true to prevent this method to throw exception when sending messagesjavax.mail.NoSuchProviderException
javax.mail.MessagingException
public static java.util.List<javax.mail.Message> sendMessage(javax.mail.Message msg, java.lang.String host, int port, java.lang.String login, java.lang.String password, boolean catchMailErrors) throws javax.mail.NoSuchProviderException, javax.mail.MessagingException
msg
- Message to be senthost
- smtp server host (null means default smtp)port
- smtp server port (<= 0 means default port)login
- login to smtp server (null means default login)password
- password to smtp server (null means default password)catchMailErrors
- set to true to prevent this method to throw exception when sending messagesjavax.mail.NoSuchProviderException
- if no SMTP provider (Transport) could be createdjavax.mail.MessagingException
public static java.util.List<javax.mail.Message> sendMessages(javax.mail.Message[] msg, java.lang.String host, int port, java.lang.String login, java.lang.String password, boolean catchMailErrors) throws javax.mail.NoSuchProviderException, javax.mail.MessagingException
msg
- array of Message to be senthost
- smtp server host (null means default smtp)port
- smtp server port (<= 0 means default port)login
- login to smtp server (null means default login)password
- password to smtp server (null means default password)catchMailErrors
- set to true to prevent this method to throw exception when sending messagesjavax.mail.NoSuchProviderException
- if no SMTP provider (Transport) could be createdjavax.mail.MessagingException
public static java.lang.String logMessage(javax.mail.Message msg) throws javax.mail.MessagingException
javax.mail.MessagingException
public static java.lang.String logAddress(javax.mail.Address[] address) throws javax.mail.MessagingException
javax.mail.MessagingException
public static java.lang.String logFlags(javax.mail.Flags.Flag[] flags) throws javax.mail.MessagingException
javax.mail.MessagingException
public static java.lang.String logHeaders(javax.mail.Message msg) throws javax.mail.MessagingException
javax.mail.MessagingException
public static javax.mail.Message buildMessage(java.lang.String from, java.lang.String recipients, java.lang.String copies, java.lang.String bcopies, java.lang.String subject, java.lang.String[] bodyPart, java.lang.String[] bodyPartEncoding, java.util.Map<java.io.File,java.lang.String> files, int priority) throws javax.mail.MessagingException
from
- the address senderrecipients
- the list of recipients separated by a commacopies
- the list of recipients in carbon copy separated by a commabcopies
- the list of recipients in blank carbon copy separated by a commasubject
- the subject of the mailbodyPart
- the body parts to be included in the mail (text, html.. etc)bodyPartEncoding
- the encodings associated to each body part (must be present for body part to be used)files
- a Map containing files to be attached to the mail. File as the key and an optionnal
String identifier as the value (value is optionnal, if left null, an id is automatically generated from the file name)priority
- priority of the message to be built, cf MailUtil.PRIORITY_*, ignored if 0 or any invalid value.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.public static javax.mail.Message buildMessage(java.lang.String from, java.lang.String recipients, java.lang.String copies, java.lang.String bcopies, java.lang.String subject, java.lang.String[] bodyPart, java.lang.String[] bodyPartEncoding, java.util.Map<java.io.File,java.lang.String> files, int priority, javax.mail.BodyPart[] bodyPartObjects) throws javax.mail.MessagingException
from
- the address senderrecipients
- the list of recipients separated by a commacopies
- the list of recipients in carbon copy separated by a commabcopies
- the list of recipients in blank carbon copy separated by a commasubject
- the subject of the mailbodyPart
- the body parts to be included in the mail (text, html.. etc)bodyPartEncoding
- the encodings associated to each body part (must be present for body part to be used)files
- a Map containing files to be attached to the mail. File as the key and an optionnal
String identifier as the value (value is optionnal, if left null, an id is automatically generated from the file name)priority
- priority of the message to be built, cf MailUtil.PRIORITY_*, ignored if 0 or any invalid value.bodyPartObjects
- array of BodyPart
to included in the mailjavax.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.Copyright © 2001-2010 Jalios SA. All Rights Reserved.