Package com.jalios.util
Class MailUtil
java.lang.Object
com.jalios.util.MailUtil
This class provides a set of static methods which perform various
utility operations for JavaMail API.
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.
- Author:
- Olivier Dedieu <olivier.dedieu@jalios.com>, Olivier Jaquemet
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String[]Predefined array of body part encoding.static final Stringstatic final Stringprotected static EmailValidatorprotected static booleanDeprecated.static final intstatic final intstatic final intstatic final intstatic final intprotected static final PropertiesDeprecated.protected static javax.mail.SessionDeprecated. -
Method Summary
Modifier and TypeMethodDescriptionstatic javax.mail.MessagebuildMessage(String from, String recipients, String copies, String bcopies, String subject, String[] bodyPart, String[] bodyPartEncoding, Map<File, String> files, int priority) Deprecated.this method is deprecated in profit of MailManager in JPlatformstatic javax.mail.MessagebuildMessage(String from, String recipients, String copies, String bcopies, String subject, String[] bodyPart, String[] bodyPartEncoding, Map<File, String> files, int priority, javax.mail.BodyPart[] bodyPartObjects) Deprecated.this method is deprecated in profit of MailManager in JPlatformstatic booleancheckEmail(String email) Checks that the given string is not empty and has a valid email syntax.static booleancheckEmailLocalPart(String localPart) Checks a Mail local part usingcheckEmail(String).static voidDeprecated.this method is deprecated in profit of MailManager in JPlatformstatic voiddisable()Deprecated.this method is deprecated in profit of MailManager in JPlatformemailsStringToEmailSet(String emails) Retrieve a Set of emails from a string of coma separated emailsstatic voidenable()Deprecated.this method is deprecated in profit of MailManager in JPlatformstatic StringgetBeautifiedEmail(String email) Convert a text email to an HTML representation.static StringgetBeautifiedEmail(String email, boolean isColored) Convert a text email to an HTML representation.static StringgetBeautifiedEmail(String email, String css1, String css2, boolean isColored) Convert an email to an HTML representation.static StringgetCanonizedEmail(String email) Canonizes an email.static StringgetCharset(String contentType) Returns charset for the given mail contentTypestatic javax.mail.internet.InternetAddressRetrieve a new InternetAddress instance (with properly encoded personnal).static Set<javax.mail.internet.InternetAddress> getIAFromMailSet(Set<String> mailSet) Returns a Set of InternetAddress from a Set of mail Stringstatic javax.mail.internet.InternetAddressgetIAQuietly(String address) Returns an InternetAddress object from the specified email addressstatic javax.mail.internet.InternetAddressgetInternetAddress(String email) Retrieve a new InternetAddress instance (with properly encoded personnal).static intgetPriority(String priority) Returns the given X-Priority String as int.
This method handles comment suffix like:"1 (Highest)"static intgetPriority(javax.mail.Message msg) Returns the given Message's X-Priority header as int.
This method handles comment suffix like:"1 (Highest)"getRecipientSet(Collection<javax.mail.Message> messages, javax.mail.Message.RecipientType type) Deprecated.the method will be removed in further release, replaced by MessageUtil methodsstatic javax.mail.SessionDeprecated.this method is deprecated in profit of MailManager in JPlatformstatic booleanhasRecipient(javax.mail.Message message) Check if the specified message has recipient.static StringlogAddress(javax.mail.Address[] address) static StringlogFlags(javax.mail.Flags.Flag[] flags) static StringlogHeaders(javax.mail.Message msg) static StringlogMessage(javax.mail.Message msg) static voidDeprecated.this method is deprecated in profit of MailManager in JPlatformstatic voidsendMail(String from, String recipients, String copies, String bcopies, String subject, String[] bodyPart, String[] bodyPartEncoding, Map<File, String> files, int priority, String host, int port, String login, String password) Deprecated.this method is deprecated in profit of MailManager in JPlatformstatic voidsendMail(String from, String recipients, String copies, String bcopies, String subject, String[] bodyPart, String[] bodyPartEncoding, Map<File, String> files, int priority, javax.mail.BodyPart[] bodyPartObjects, String host, int port, String login, String password) Deprecated.this method is deprecated in profit of MailManager in JPlatformstatic voidsendMail(String from, String recipients, String copies, String bcopies, String subject, String bodyText, Map<File, String> files, int priority) Deprecated.this method is deprecated in profit of MailManager in JPlatformstatic voidsendMail(String from, String recipients, String copies, String bcopies, String subject, String bodyText, Map<File, String> files, int priority, String host, int port, String login, String password) Deprecated.this method is deprecated in profit of MailManager in JPlatformstatic voidsendMail(String from, String recipients, String subject, String bodyText, Map<File, String> files, int priority) Deprecated.this method is deprecated in profit of MailManager in JPlatformDeprecated.this method is deprecated in profit of MailManager in JPlatformsendMails(String from, String recipients, String copies, String bcopies, String subject, String[] bodyPart, String[] bodyPartEncoding, Map<File, String> files, int priority, String host, int port, String login, String password) Deprecated.this method is deprecated in profit of MailManager in JPlatformsendMails(String from, String recipients, String copies, String bcopies, String subject, String[] bodyPart, String[] bodyPartEncoding, Map<File, String> files, int priority, javax.mail.BodyPart[] bodyPartObjects, String host, int port, String login, String password) Deprecated.this method is deprecated in profit of MailManager in JPlatformsendMails(String from, String recipients, String copies, String bcopies, String subject, String bodyText, Map<File, String> files, int priority) Deprecated.this method is deprecated in profit of MailManager in JPlatformsendMails(String from, String recipients, String copies, String bcopies, String subject, String bodyText, Map<File, String> files, int priority, String host, int port, String login, String password) Deprecated.this method is deprecated in profit of MailManager in JPlatformsendMails(String from, String recipients, String subject, String bodyText, Map<File, String> files, int priority) Deprecated.this method is deprecated in profit of MailManager in JPlatformstatic List<javax.mail.Message> sendMessage(javax.mail.Message msg, boolean catchMailErrors) Deprecated.this method is deprecated in profit of MailManager in JPlatformstatic List<javax.mail.Message> sendMessage(javax.mail.Message msg, String host, int port, String login, String password, boolean catchMailErrors) Deprecated.this method is deprecated in profit of MailManager in JPlatformstatic List<javax.mail.Message> sendMessages(javax.mail.Message[] msg, boolean catchMailErrors) Deprecated.this method is deprecated in profit of MailManager in JPlatformstatic List<javax.mail.Message> sendMessages(javax.mail.Message[] msg, String host, int port, String login, String password, boolean catchMailErrors) Deprecated.this method is deprecated in profit of MailManager in JPlatformstatic voidsetEmailValidator(EmailValidator validator) Sets the email validator to use.
-
Field Details
-
BODYPART_TEXT_PLAIN_ENCODING
- See Also:
-
BODYPART_TEXT_HTML_ENCODING
- See Also:
-
PRIORITY_HIGHEST
public static final int PRIORITY_HIGHEST- See Also:
-
PRIORITY_HIGH
public static final int PRIORITY_HIGH- See Also:
-
PRIORITY_NORMAL
public static final int PRIORITY_NORMAL- See Also:
-
PRIORITY_LOW
public static final int PRIORITY_LOW- See Also:
-
PRIORITY_LOWEST
public static final int PRIORITY_LOWEST- See Also:
-
BODYPART_ENCODINGS
Predefined array of body part encoding.- First part is
MailUtil.BODYPART_TEXT_PLAIN_ENCODING. - Second part is
MailUtil.BODYPART_TEXT_HTML_ENCODING.
- First part is
-
props
Deprecated. -
session
Deprecated. -
enabled
Deprecated. -
EMAIL_VALIDATOR
-
-
Method Details
-
configure
@Deprecated public static void configure(String host, String port, String login, String password, Properties addedProps) Deprecated.this method is deprecated in profit of MailManager in JPlatformConfigure MailUtil properties (of javax.mail.Session) using the given values.- Parameters:
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.
-
enable
Deprecated.this method is deprecated in profit of MailManager in JPlatformEnable MailUtil, that is all call to methods of MailUtil will send mail using the configuration given during call toconfigure(String, String, String, String, Properties). -
disable
Deprecated.this method is deprecated in profit of MailManager in JPlatformDisable MailUtil, that is all call to methods of MailUtil will results in log message and no mail is ever send. -
getSession
Deprecated.this method is deprecated in profit of MailManager in JPlatformRetrieve the session being used to send mails.- Returns:
- a configured Session object
-
getIAFromMailSet
public static Set<javax.mail.internet.InternetAddress> getIAFromMailSet(Set<String> mailSet) throws javax.mail.MessagingException Returns a Set of InternetAddress from a Set of mail String- Parameters:
mailSet- Set of mail String- Returns:
- Set of InternetAddress
- Throws:
javax.mail.MessagingException
-
getIAQuietly
Returns an InternetAddress object from the specified email address- Parameters:
address- the email address. (eg:"John Smith" <john.smith@example.com>)- Returns:
- InternetAddress
-
getIA
public static javax.mail.internet.InternetAddress getIA(String email) throws javax.mail.internet.AddressException Retrieve a new InternetAddress instance (with properly encoded personnal).- Parameters:
email- the email address. (eg:"John Smith" <john.smith@example.com>)- Returns:
- a new InternetAddress object
- Throws:
javax.mail.internet.AddressException- if the email address could not be parsed.- Since:
- jcms-5.7.6, jcms-6.1.2, jcms-6.2
-
getInternetAddress
public static javax.mail.internet.InternetAddress getInternetAddress(String email) throws javax.mail.internet.AddressException Retrieve a new InternetAddress instance (with properly encoded personnal).- Parameters:
email- the email address. (eg:"John Smith" <john.smith@example.com>)- Returns:
- a new InternetAddress object
- Throws:
javax.mail.internet.AddressException- if the email address could not be parsed.- Since:
- jcms-5.7.6, jcms-6.1.2, jcms-6.2
-
checkEmail
Checks that the given string is not empty and has a valid email syntax.- Parameters:
email- the email to be checked- Returns:
- true if the email is valid, false otherwise
-
setEmailValidator
Sets the email validator to use.- Parameters:
validator- the email validator to use.- Since:
- jcms-10.0.6
- See Also:
-
checkEmailLocalPart
Checks a Mail local part usingcheckEmail(String).- Parameters:
localPart- the local part to test its validity.- Returns:
- true if
checkEmail(localPart + "@example.com")is valid. - Since:
- jcms-9.0.0
- See Also:
-
getCanonizedEmail
Canonizes an email. Example, returnsolivier.dedieu@inria.frforOlivier Dedieu <olivier.dedieu@inria.fr>- Parameters:
email- the email to be canonized- Returns:
- the canonized email
-
getPriority
public static int getPriority(javax.mail.Message msg) Returns the given Message's X-Priority header as int.
This method handles comment suffix like:"1 (Highest)"If no valid priority does match, returns
PRIORITY_NORMALby default.
A valid priority is in range [1, 5], as the following:- 1 (Highest)
- 2 (High)
- 3 (Normal)
- 4 (Low)
- 5 (Lowest)
- Parameters:
msg- the message to retrieve its X-Priority header.- Returns:
- the X-Priority from 1 (Highest) to 5 (Lowest)
- Since:
- jcms-7.1.4, jcms-8.0.3, jcms-9.0.0
- See Also:
-
getPriority
Returns the given X-Priority String as int.
This method handles comment suffix like:"1 (Highest)"If no valid priority does match, returns
PRIORITY_NORMALby default.
A valid priority is in range [1, 5], as the following:- 1 (Highest)
- 2 (High)
- 3 (Normal)
- 4 (Low)
- 5 (Lowest)
- Parameters:
priority- the priority as String- Returns:
- the X-Priority from 1 (Highest) to 5 (Lowest)
- Since:
- jcms-7.1.4, jcms-8.0.3, jcms-9.0.0
- See Also:
-
getRecipientSet
@Deprecated public static TreeSet<String> getRecipientSet(Collection<javax.mail.Message> messages, javax.mail.Message.RecipientType type) Deprecated.the method will be removed in further release, replaced by MessageUtil methodsUtility method which create a TreeSet of all recipients email from the specified messages.- Parameters:
messages- the message in which to retrieve recipientstype- the type of recipient to find, if null, all recipient are used- Returns:
- a Set of email, never return null.
- Since:
- jcms-6.1
-
emailsStringToEmailSet
Retrieve a Set of emails from a string of coma separated emails- Parameters:
emails- a string containing one or several mail addresses seperated with coma, e.g"Foo Bar" <foobar@company.com>, "John Smith" <js@company.com>- Returns:
- a Set of unique email address, never return null.
-
getCharset
Returns charset for the given mail contentType- Parameters:
contentType- the contentType header- Returns:
- String decoded charset
-
getBeautifiedEmail
Convert a text email to an HTML representation.Invokes
getBeautifiedEmail(String, String, String, boolean)with css1="label" and css2="email" and no color.- Parameters:
email- the email String representation- Returns:
- String HTML representation
-
getBeautifiedEmail
Convert a text email to an HTML representation.Invokes
getBeautifiedEmail(String, String, String, boolean)with css1="label" and css2="email".- Parameters:
email- the email String representationisColored- will set a color- Returns:
- String HTML representation
-
getBeautifiedEmail
Convert an email to an HTML representation.- Given string "
"FirstName LastName" <first.last@company.com>"
output is :<span class="css1">"FirstName LastName"</span> <span class="css2"><first.last@company.com></span>
- Given string "
FirstName LastName <first.last@company.com>"
output is :<span class="css1">FirstName LastName</span> <span class="css2"><first.last@company.com></span>
- Given string "
first.last@company.com"
output is :<span class="css1">first.last@company.com</span>
- Parameters:
email- the email String representationcss1- the first css to applycss2- the second css to applyisColored- true to add a style attribute to the first span, with a text color computed from the email value- Returns:
- String HTML representation
- Given string "
-
hasRecipient
public static boolean hasRecipient(javax.mail.Message message) Check if the specified message has recipient.- Parameters:
message- the message to check- Returns:
- true if the message has at least one recipient (TO, CC or BCC), false otherwise and if the message is null
- Since:
- jcms-6.2, jcms-6.1.3
-
sendMail
@Deprecated public static void sendMail(String from, String recipients, String subject, String bodyText) throws javax.mail.NoSuchProviderException, javax.mail.MessagingException Deprecated.this method is deprecated in profit of MailManager in JPlatformSend 1 Mail to all the given recipients.- Parameters:
from- the address senderrecipients- the list of recipients separated by a commasubject- the subject of the mailbodyText- the body of the mail (plain text)- Throws:
javax.mail.NoSuchProviderException- if no SMTP provider (Transport) could be createdjavax.mail.MessagingException
-
sendMail
@Deprecated public static void sendMail(String from, String recipients, String subject, String bodyText, Map<File, String> files, int priority) throws javax.mail.NoSuchProviderException, javax.mail.MessagingExceptionDeprecated.this method is deprecated in profit of MailManager in JPlatformSend 1 Mail to all the given recipients.- Parameters:
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 optional String identifier as the value (value is optional, 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.- Throws:
javax.mail.NoSuchProviderException- if no SMTP provider (Transport) could be createdjavax.mail.MessagingException
-
sendMail
@Deprecated public static void sendMail(String from, String recipients, String copies, String bcopies, String subject, String bodyText, Map<File, String> files, int priority) throws javax.mail.NoSuchProviderException, javax.mail.MessagingExceptionDeprecated.this method is deprecated in profit of MailManager in JPlatformSend 1 Mail to all the given recipients.- Parameters:
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 optional String identifier as the value (value is optional, 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.- Throws:
javax.mail.NoSuchProviderException- if no SMTP provider (Transport) could be createdjavax.mail.MessagingException
-
sendMail
@Deprecated public static void sendMail(String from, String recipients, String copies, String bcopies, String subject, String bodyText, Map<File, String> files, int priority, String host, int port, String login, String password) throws javax.mail.NoSuchProviderException, javax.mail.MessagingExceptionDeprecated.this method is deprecated in profit of MailManager in JPlatformSend 1 Mail to all the given recipients.- Parameters:
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 optional String identifier as the value (value is optional, 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)- Throws:
javax.mail.NoSuchProviderException- if no SMTP provider (Transport) could be createdjavax.mail.MessagingException
-
sendMail
@Deprecated public static void sendMail(String from, String recipients, String copies, String bcopies, String subject, String[] bodyPart, String[] bodyPartEncoding, Map<File, String> files, int priority, String host, int port, String login, String password) throws javax.mail.NoSuchProviderException, javax.mail.MessagingExceptionDeprecated.this method is deprecated in profit of MailManager in JPlatformSend 1 Mail to all the given recipients.- Parameters:
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 optional String identifier as the value (value is optional, 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)- Throws:
javax.mail.NoSuchProviderException- if no SMTP provider (Transport) could be createdjavax.mail.MessagingException
-
sendMail
@Deprecated public static void sendMail(String from, String recipients, String copies, String bcopies, String subject, String[] bodyPart, String[] bodyPartEncoding, Map<File, String> files, int priority, javax.mail.BodyPart[] bodyPartObjects, String host, int port, String login, String password) throws javax.mail.NoSuchProviderException, javax.mail.MessagingExceptionDeprecated.this method is deprecated in profit of MailManager in JPlatformSend 1 Mail to all the given recipients.- Parameters:
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 optional String identifier as the value (value is optional, 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 ofBodyPartto 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)- Throws:
javax.mail.NoSuchProviderException- if no SMTP provider (Transport) could be createdjavax.mail.MessagingException
-
sendMails
@Deprecated public static List<String> sendMails(String from, String recipients, String subject, String bodyText) Deprecated.this method is deprecated in profit of MailManager in JPlatformSend 1 mail for each given recipients.- Parameters:
from- the address senderrecipients- the list of recipients separated by a commasubject- the subject of the mailbodyText- the body of the mail (plain text)- Returns:
- a list of recipient String for which an exception was thrown during sending of mails
-
sendMails
@Deprecated public static List<String> sendMails(String from, String recipients, String subject, String bodyText, Map<File, String> files, int priority) Deprecated.this method is deprecated in profit of MailManager in JPlatformSend 1 mail for each given recipients. This is a shorter Method using basic parameters. All other parameters are guest from properties. Warning: This method only fail and return a list of error when a Message could not be build or sent, but it DOES not faild and return anything when the connection to the smtp server cannot be established.- Parameters:
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 optional String identifier as the value (value is optional, 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.- Returns:
- a list of recipient String for which an exception was thrown during sending of mails
-
sendMails
@Deprecated public static List<String> sendMails(String from, String recipients, String copies, String bcopies, String subject, String bodyText, Map<File, String> files, int priority) Deprecated.this method is deprecated in profit of MailManager in JPlatformSend n Mails. Do not throw exceptions. This is a shorter Method using basic parameters. All other parameters are guest from properties. Warning: This method only fail and return a list of error when a Message could not be build or sent, but it DOES not faild and return anything when the connection to the smtp server cannot be established.- Parameters:
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 optional String identifier as the value (value is optional, 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.- Returns:
- a list of recipient String that throws exceptions during sending of mails
-
sendMails
@Deprecated public static List<String> sendMails(String from, String recipients, String copies, String bcopies, String subject, String bodyText, Map<File, String> files, int priority, String host, int port, String login, String password) Deprecated.this method is deprecated in profit of MailManager in JPlatformSend n Mails. Do not throw exceptions. This is a shorter Method using basic parameters. All other parameters are guest from properties. Warning: This method only fail and return a list of error when a Message could not be build or sent, but it DOES not faild and return anything when the connection to the smtp server cannot be established.- Parameters:
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 optional String identifier as the value (value is optional, 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 used- Returns:
- a list of recipient String that throws exceptions during sending of mails
-
sendMails
@Deprecated public static List<String> sendMails(String from, String recipients, String copies, String bcopies, String subject, String[] bodyPart, String[] bodyPartEncoding, Map<File, String> files, int priority, String host, int port, String login, String password) Deprecated.this method is deprecated in profit of MailManager in JPlatformSend n Mails. Do not throw exceptions. This is the most complete Method using basic parameters. Warning: This method only fail and return a list of error when a Message could not be build or sent, but it DOES not faild and return anything when the connection to the smtp server cannot be established.- Parameters:
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 optional String identifier as the value (value is optional, 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 used- Returns:
- a list of recipient String that throws exceptions during sending of mails
-
sendMails
@Deprecated public static List<String> sendMails(String from, String recipients, String copies, String bcopies, String subject, String[] bodyPart, String[] bodyPartEncoding, Map<File, String> files, int priority, javax.mail.BodyPart[] bodyPartObjects, String host, int port, String login, String password) Deprecated.this method is deprecated in profit of MailManager in JPlatformSend n Mails. Do not throw exceptions. This is the most complete Method using basic parameters. Warning: This method only fail and return a list of error when a Message could not be build or sent, but it DOES not faild and return anything when the connection to the smtp server cannot be established.- Parameters:
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 optional String identifier as the value (value is optional, 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 ofBodyPartto included in the mailhost- not usedport- not usedlogin- not usedpassword- not used- Returns:
- a list of recipient String that throws exceptions during sending of mails
-
sendMessage
@Deprecated public static List<javax.mail.Message> sendMessage(javax.mail.Message msg, boolean catchMailErrors) throws javax.mail.NoSuchProviderException, javax.mail.MessagingException Deprecated.this method is deprecated in profit of MailManager in JPlatformSend given message.- Parameters:
msg- Message to be sentcatchMailErrors- set to true to prevent this method to throw exception when sending messages- Returns:
- null if catchMailErrors is false, a List of Message that could not be sent if catchMailErrors is true
- Throws:
javax.mail.NoSuchProviderException- if no SMTP provider (Transport) could be createdjavax.mail.MessagingException
-
sendMessages
@Deprecated public static List<javax.mail.Message> sendMessages(javax.mail.Message[] msg, boolean catchMailErrors) throws javax.mail.NoSuchProviderException, javax.mail.MessagingException Deprecated.this method is deprecated in profit of MailManager in JPlatformSend given messages.- Parameters:
msg- array of Message to be sentcatchMailErrors- set to true to prevent this method to throw exception when sending messages- Returns:
- null if catchMailErrors is false, a List of Message that could not be sent if catchMailErrors is true
- Throws:
javax.mail.NoSuchProviderExceptionjavax.mail.MessagingException
-
sendMessage
@Deprecated public static List<javax.mail.Message> sendMessage(javax.mail.Message msg, String host, int port, String login, String password, boolean catchMailErrors) throws javax.mail.NoSuchProviderException, javax.mail.MessagingException Deprecated.this method is deprecated in profit of MailManager in JPlatformSend the given message with the given smtp parameters.- Parameters:
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 messages- Returns:
- null if catchMailErrors is false, a List of Message that could not be sent if catchMailErrors is true
- Throws:
javax.mail.NoSuchProviderException- if no SMTP provider (Transport) could be createdjavax.mail.MessagingException
-
sendMessages
@Deprecated public static List<javax.mail.Message> sendMessages(javax.mail.Message[] msg, String host, int port, String login, String password, boolean catchMailErrors) throws javax.mail.NoSuchProviderException, javax.mail.MessagingException Deprecated.this method is deprecated in profit of MailManager in JPlatformSend given messages.- Parameters:
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 messages- Returns:
- null if catchMailErrors is false, a List of Message that could not be sent if catchMailErrors is true
- Throws:
javax.mail.NoSuchProviderException- if no SMTP provider (Transport) could be createdjavax.mail.MessagingException
-
logMessage
- Throws:
javax.mail.MessagingException
-
logAddress
- Throws:
javax.mail.MessagingException
-
logFlags
- Throws:
javax.mail.MessagingException
-
logHeaders
- Throws:
javax.mail.MessagingException
-
buildMessage
@Deprecated public static javax.mail.Message buildMessage(String from, String recipients, String copies, String bcopies, String subject, String[] bodyPart, String[] bodyPartEncoding, Map<File, String> files, int priority) throws javax.mail.MessagingExceptionDeprecated.this method is deprecated in profit of MailManager in JPlatformBuild a MimeMessage bodyPartEncoding values are: text/plain; charset=UTF-8 | text/html; charset=UTF-8- Parameters:
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 optional String identifier as the value (value is optional, 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.- 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.
-
buildMessage
@Deprecated public static javax.mail.Message buildMessage(String from, String recipients, String copies, String bcopies, String subject, String[] bodyPart, String[] bodyPartEncoding, Map<File, String> files, int priority, javax.mail.BodyPart[] bodyPartObjects) throws javax.mail.MessagingExceptionDeprecated.this method is deprecated in profit of MailManager in JPlatformBuild a MimeMessage bodyPartEncoding values are: text/plain; charset=UTF-8 | text/html; charset=UTF-8- Parameters:
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 optional String identifier as the value (value is optional, 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 ofBodyPartto included in the mail- 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.
-