public final class SendMailHelper extends AbstractLogEnabled implements Disposable
Modifier and Type | Class and Description |
---|---|
private static class |
SendMailHelper.CssRule |
private static class |
SendMailHelper.CssSpecificity |
private static class |
SendMailHelper.MailSender |
private static class |
SendMailHelper.MailSenderThreadFactory |
Modifier and Type | Field and Description |
---|---|
protected static Pattern |
__CSS_SPECIFICITY_ATTR_PATTERN
Attribute selectors pattern for CSS specificity processing
|
protected static Pattern |
__CSS_SPECIFICITY_CLASS_PATTERN
Class selectors pattern for CSS specificity processing
|
protected static Pattern |
__CSS_SPECIFICITY_ELEMENT_PATTERN
Element selectors pattern for CSS specificity processing
|
protected static Pattern |
__CSS_SPECIFICITY_ID_PATTERN
ID selectors pattern for CSS specificity processing
|
protected static Pattern |
__CSS_SPECIFICITY_PSEUDO_CLASS_NOT_PATTERN
Specific :not pseudo-class selectors pattern for CSS specificity processing
|
protected static Pattern |
__CSS_SPECIFICITY_PSEUDO_CLASS_PATTERN
Pseudo-class selectors pattern for CSS specificity processing
|
protected static Pattern |
__CSS_SPECIFICITY_PSEUDO_CLASS_WITH_BRACKETS_PATTERN
Pseudo-class (with bracket) selectors pattern for CSS specificity processing
|
protected static Pattern |
__CSS_SPECIFICITY_PSEUDO_ELEMENT_PATTERN
Pseudo-element selectors pattern for CSS specificity processing
|
protected static Pattern |
__CSS_SPECIFICITY_UNIVERSAL_AND_SEPARATOR_PATTERN
Universal and separator characters pattern for CSS specificity processing
|
private static ExecutorService |
__SINGLE_THREAD_EXECUTOR |
protected static Logger |
_LOGGER
Logger
|
Modifier | Constructor and Description |
---|---|
private |
SendMailHelper() |
Modifier and Type | Method and Description |
---|---|
private static String |
_removeComments(String styleRules) |
private static String |
concatenateProperties(String oldProp,
String newProp) |
void |
dispose() |
static String |
inlineCSS(String html)
This method inline css in <style> tags directly in the appropriates tags.
|
static void |
sendMail(String subject,
String htmlBody,
String textBody,
Collection<File> attachments,
String recipient,
String sender)
Sends mail without authentication, with attachments.
|
static void |
sendMail(String subject,
String htmlBody,
String textBody,
Collection<File> attachments,
String recipient,
String sender,
List<String> cc,
List<String> bcc,
boolean async)
Sends mail without authentication, with attachments.
|
static void |
sendMail(String subject,
String htmlBody,
String textBody,
Collection<File> attachments,
String recipient,
String sender,
List<String> cc,
List<String> bcc,
boolean deliveryReceipt,
boolean readReceipt,
boolean async)
Sends mail without authentication, with attachments.
|
static void |
sendMail(String subject,
String htmlBody,
String textBody,
Collection<File> attachments,
String recipient,
String sender,
List<String> cc,
List<String> bcc,
boolean deliveryReceipt,
boolean readReceipt,
String host,
long port,
String securityProtocol,
boolean async)
Sends mail without authentication, with attachments.
|
static void |
sendMail(String subject,
String htmlBody,
String textBody,
Collection<File> attachments,
String recipient,
String sender,
List<String> cc,
List<String> bcc,
boolean deliveryReceipt,
boolean readReceipt,
String host,
long port,
String securityProtocol,
String user,
String password,
boolean async)
Sends mail with authentication and attachments.
|
static void |
sendMail(String subject,
String htmlBody,
String textBody,
String recipient,
String sender)
Sends mail without authentication or attachments.
|
static void |
sendMail(String subject,
String htmlBody,
String textBody,
String recipient,
String sender,
boolean async)
Sends mail without authentication or attachments.
|
static void |
sendMail(String subject,
String htmlBody,
String textBody,
String recipient,
String sender,
String host,
long port,
String securityProtocol,
boolean async)
Sends mail without authentication or attachments.
|
static void |
sendMail(String subject,
String htmlBody,
String textBody,
String recipient,
String sender,
String host,
long port,
String securityProtocol,
String user,
String password,
boolean async)
Sends mail with authentication, without attachments.
|
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
protected static final Pattern __CSS_SPECIFICITY_ATTR_PATTERN
protected static final Pattern __CSS_SPECIFICITY_ID_PATTERN
protected static final Pattern __CSS_SPECIFICITY_CLASS_PATTERN
protected static final Pattern __CSS_SPECIFICITY_PSEUDO_ELEMENT_PATTERN
protected static final Pattern __CSS_SPECIFICITY_PSEUDO_CLASS_WITH_BRACKETS_PATTERN
protected static final Pattern __CSS_SPECIFICITY_PSEUDO_CLASS_PATTERN
protected static final Pattern __CSS_SPECIFICITY_ELEMENT_PATTERN
protected static final Pattern __CSS_SPECIFICITY_PSEUDO_CLASS_NOT_PATTERN
protected static final Pattern __CSS_SPECIFICITY_UNIVERSAL_AND_SEPARATOR_PATTERN
private static final ExecutorService __SINGLE_THREAD_EXECUTOR
private SendMailHelper()
public static void sendMail(String subject, String htmlBody, String textBody, String recipient, String sender) throws javax.mail.MessagingException
subject
- The mail subjecthtmlBody
- The HTML mail body. Can be null.textBody
- The text mail body. Can be null.recipient
- The recipient addresssender
- The sender addressjavax.mail.MessagingException
- If an error occurred while preparing or sending emailpublic static void sendMail(String subject, String htmlBody, String textBody, String recipient, String sender, boolean async) throws javax.mail.MessagingException
subject
- The mail subjecthtmlBody
- The HTML mail body. Can be null.textBody
- The text mail body. Can be null.recipient
- The recipient addresssender
- The sender addressasync
- True to use asynchronous mail sendingjavax.mail.MessagingException
- If an error occurred while preparing or sending emailpublic static void sendMail(String subject, String htmlBody, String textBody, String recipient, String sender, String host, long port, String securityProtocol, boolean async) throws javax.mail.MessagingException
subject
- The mail subjecthtmlBody
- The HTML mail body. Can be null.textBody
- The text mail body. Can be null.recipient
- The recipient addresssender
- The sender addresshost
- The server mail hostport
- The server mail portsecurityProtocol
- The server mail security protocolasync
- True to use asynchronous mail sendingjavax.mail.MessagingException
- If an error occurred while preparing or sending emailpublic static void sendMail(String subject, String htmlBody, String textBody, String recipient, String sender, String host, long port, String securityProtocol, String user, String password, boolean async) throws javax.mail.MessagingException
subject
- The mail subjecthtmlBody
- The HTML mail body. Can be null.textBody
- The text mail body. Can be null.recipient
- The recipient addresssender
- The sender addresshost
- The server mail hostport
- The server portsecurityProtocol
- The server mail security protocoluser
- The user namepassword
- The user passwordasync
- True to use asynchronous mail sendingjavax.mail.MessagingException
- If an error occurred while preparing or sending emailpublic static void sendMail(String subject, String htmlBody, String textBody, Collection<File> attachments, String recipient, String sender) throws javax.mail.MessagingException, IOException
subject
- The mail subjecthtmlBody
- The HTML mail body. Can be null.textBody
- The text mail body. Can be null.attachments
- the file attachments. Can be null.recipient
- The recipient addresssender
- The sender addressjavax.mail.MessagingException
- If an error occurred while preparing or sending emailIOException
- if an error occurs while attaching a file.public static void sendMail(String subject, String htmlBody, String textBody, Collection<File> attachments, String recipient, String sender, List<String> cc, List<String> bcc, boolean async) throws javax.mail.MessagingException, IOException
subject
- The mail subjecthtmlBody
- The HTML mail body. Can be null.textBody
- The text mail body. Can be null.attachments
- the file attachments. Can be null.recipient
- The recipient addresssender
- The sender addresscc
- Carbon copy address list. Can be null.bcc
- Blind carbon copy address list. Can be null.async
- True to use asynchronous mail sendingjavax.mail.MessagingException
- If an error occurred while preparing or sending emailIOException
- if an error occurs while attaching a file.public static void sendMail(String subject, String htmlBody, String textBody, Collection<File> attachments, String recipient, String sender, List<String> cc, List<String> bcc, boolean deliveryReceipt, boolean readReceipt, boolean async) throws javax.mail.MessagingException, IOException
subject
- The mail subjecthtmlBody
- The HTML mail body. Can be null.textBody
- The text mail body. Can be null.attachments
- the file attachments. Can be null.recipient
- The recipient addresssender
- The sender addresscc
- Carbon copy address list. Can be null.bcc
- Blind carbon copy address list. Can be null.deliveryReceipt
- true to request that the receiving mail server send a notification when the mail is received.readReceipt
- true to request that the receiving mail client send a notification when the person opens the mail.async
- True to use asynchronous mail sendingjavax.mail.MessagingException
- If an error occurred while preparing or sending emailIOException
- if an error occurs while attaching a file.public static void sendMail(String subject, String htmlBody, String textBody, Collection<File> attachments, String recipient, String sender, List<String> cc, List<String> bcc, boolean deliveryReceipt, boolean readReceipt, String host, long port, String securityProtocol, boolean async) throws javax.mail.MessagingException, IOException
subject
- The mail subjecthtmlBody
- The HTML mail body. Can be null.textBody
- The text mail body. Can be null.attachments
- the file attachments. Can be null.recipient
- The recipient addresssender
- The sender addresscc
- Carbon copy address list. Can be null.bcc
- Blind carbon copy address list. Can be null.deliveryReceipt
- true to request that the receiving mail server send a notification when the mail is received.readReceipt
- true to request that the receiving mail client send a notification when the person opens the mail.host
- The server mail hostport
- The server portsecurityProtocol
- The server mail security protocolasync
- True to use asynchronous mail sendingjavax.mail.MessagingException
- If an error occurred while preparing or sending emailIOException
- if an error occurs while attaching a file.public static void sendMail(String subject, String htmlBody, String textBody, Collection<File> attachments, String recipient, String sender, List<String> cc, List<String> bcc, boolean deliveryReceipt, boolean readReceipt, String host, long port, String securityProtocol, String user, String password, boolean async) throws javax.mail.MessagingException, IOException
subject
- The mail subjecthtmlBody
- The HTML mail body. Can be null.textBody
- The text mail body. Can be null.attachments
- the file attachments. Can be null.recipient
- The recipient addresssender
- The sender address. Can be null when called by MailChecker.cc
- Carbon copy address list. Can be null.bcc
- Blind carbon copy address list. Can be null.deliveryReceipt
- true to request that the receiving mail server send a notification when the mail is received.readReceipt
- true to request that the receiving mail client send a notification when the person opens the mail.host
- The server mail host. Can be null when called by MailChecker.securityProtocol
- the security protocol to use when transporting the emailport
- The server portuser
- The user namepassword
- The user passwordasync
- True to use asynchronous mail sendingjavax.mail.MessagingException
- If an error occurred while preparing or sending emailIOException
- if an error occurs while attaching a file.public static String inlineCSS(String html)
html
- The initial non null htmlprivate static String _removeComments(String styleRules)
private static String concatenateProperties(String oldProp, String newProp)
public void dispose()
dispose
in interface Disposable