public class MailService extends Object
Modifier and Type | Class and Description |
---|---|
static class |
MailService.Attachment |
Modifier and Type | Field and Description |
---|---|
static String |
HIDDEN_DIV |
protected static Logger |
logger
create a static logger.
|
static String |
MAILING_ID_MAIL_KEY |
static String |
SMTP_HOST_PARAM |
static String |
SMTP_PASSWORD_PARAM |
static String |
SMTP_PORT_PARAM |
static String |
SMTP_USER_PARAM |
Modifier and Type | Method and Description |
---|---|
static String |
_messageToDKIMBody(javax.mail.internet.MimeMultipart part) |
static MailService |
getInstance(MailConfig mailConfig)
This method is kept to be able to use this class outside a Servlet
context
|
MailConfig |
getMailConfig() |
static javax.mail.Session |
getMailSession(MailConfig mailConfig) |
static javax.mail.Transport |
getMailTransport(MailConfig mailConfig) |
static void |
main(String[] args) |
static String |
messageToDKIMBody(javax.mail.internet.MimeMultipart msg,
OutputStream out) |
static String |
messageToText(javax.mail.internet.MimeMultipart part) |
static void |
resetInstance() |
void |
sendMail(GlobalContext globalContext,
javax.mail.internet.InternetAddress sender,
javax.mail.internet.InternetAddress recipient,
String subject,
String content,
boolean isHTML) |
void |
sendMail(javax.mail.internet.InternetAddress sender,
javax.mail.internet.InternetAddress recipient,
String subject,
String content,
boolean isHTML) |
void |
sendMail(javax.mail.internet.InternetAddress sender,
javax.mail.internet.InternetAddress recipient,
String subject,
String content,
boolean isHTML,
DKIMBean dkim) |
String |
sendMail(javax.mail.Transport transport,
EMail email) |
void |
sendMail(javax.mail.Transport transport,
javax.mail.internet.InternetAddress sender,
javax.mail.internet.InternetAddress recipient,
javax.mail.internet.InternetAddress ccRecipient,
javax.mail.internet.InternetAddress bccRecipient,
String subject,
String content,
boolean isHTML) |
void |
sendMail(javax.mail.Transport transport,
javax.mail.internet.InternetAddress sender,
javax.mail.internet.InternetAddress recipient,
javax.mail.internet.InternetAddress ccRecipient,
javax.mail.internet.InternetAddress bccRecipient,
String subject,
String content,
String contentTxt,
boolean isHTML,
DKIMBean dkimBean) |
String |
sendMail(javax.mail.Transport transport,
javax.mail.internet.InternetAddress sender,
javax.mail.internet.InternetAddress recipient,
List<javax.mail.internet.InternetAddress> ccRecipients,
List<javax.mail.internet.InternetAddress> bccRecipients,
String subject,
String content,
boolean isHTML,
String unsubribeLink,
DKIMBean dkinBean)
Send one mail to one recipient and multiple BCC recipients (in one mail).
|
void |
sendMail(javax.mail.Transport transport,
javax.mail.internet.InternetAddress sender,
javax.mail.internet.InternetAddress recipient,
String subject,
String content,
boolean isHTML,
String unsubribeLink)
Send one mail to one recipient.
|
String |
sendMail(javax.mail.Transport transport,
javax.mail.internet.InternetAddress sender,
javax.mail.internet.InternetAddress recipient,
String subject,
String content,
boolean isHTML,
String unsubribeLink,
DKIMBean dkinBean,
String mailId) |
static void |
writeEMLFile(String subject,
String body,
OutputStream out) |
public static final String HIDDEN_DIV
public static final String MAILING_ID_MAIL_KEY
public static final String SMTP_HOST_PARAM
public static final String SMTP_PORT_PARAM
public static final String SMTP_USER_PARAM
public static final String SMTP_PASSWORD_PARAM
protected static Logger logger
public static MailService getInstance(MailConfig mailConfig)
mailConfig
- config for mailing.public static final javax.mail.Session getMailSession(MailConfig mailConfig) throws javax.mail.MessagingException
javax.mail.MessagingException
public static final javax.mail.Transport getMailTransport(MailConfig mailConfig) throws javax.mail.MessagingException
javax.mail.MessagingException
public String sendMail(javax.mail.Transport transport, EMail email) throws javax.mail.MessagingException
javax.mail.MessagingException
public String sendMail(javax.mail.Transport transport, javax.mail.internet.InternetAddress sender, javax.mail.internet.InternetAddress recipient, List<javax.mail.internet.InternetAddress> ccRecipients, List<javax.mail.internet.InternetAddress> bccRecipients, String subject, String content, boolean isHTML, String unsubribeLink, DKIMBean dkinBean) throws javax.mail.MessagingException
transport
- transport connection, if null transport is create inside the
methodsender
- the "From" fieldrecipient
- the "To" fieldbccRecipients
- the "Bcc" field with multiple addresses.subject
- the Subject of the messagecontent
- the Content of the messageisHTML
- flag indicating wether the Content is html (true
)
or text (false
)javax.mail.MessagingException
- Forwarded exception from javax.mailIllegalArgumentException
- if no recipient provided or no senderpublic void sendMail(javax.mail.Transport transport, javax.mail.internet.InternetAddress sender, javax.mail.internet.InternetAddress recipient, javax.mail.internet.InternetAddress ccRecipient, javax.mail.internet.InternetAddress bccRecipient, String subject, String content, boolean isHTML) throws javax.mail.MessagingException
javax.mail.MessagingException
public void sendMail(javax.mail.Transport transport, javax.mail.internet.InternetAddress sender, javax.mail.internet.InternetAddress recipient, javax.mail.internet.InternetAddress ccRecipient, javax.mail.internet.InternetAddress bccRecipient, String subject, String content, String contentTxt, boolean isHTML, DKIMBean dkimBean) throws javax.mail.MessagingException
javax.mail.MessagingException
public MailConfig getMailConfig()
public void sendMail(javax.mail.Transport transport, javax.mail.internet.InternetAddress sender, javax.mail.internet.InternetAddress recipient, String subject, String content, boolean isHTML, String unsubribeLink) throws javax.mail.MessagingException
transport
- transport connection, if null transport is create inside the
methodsender
- the "From" fieldrecipient
- the "To" fieldsubject
- the Subject of the messagecontent
- the Content of the messageisHTML
- flag indicating wether the Content is html (true
)
or text (false
)javax.mail.MessagingException
- Forwarded exception from javax.mailIllegalArgumentException
- if no recipient provided or no senderpublic String sendMail(javax.mail.Transport transport, javax.mail.internet.InternetAddress sender, javax.mail.internet.InternetAddress recipient, String subject, String content, boolean isHTML, String unsubribeLink, DKIMBean dkinBean, String mailId) throws javax.mail.MessagingException
javax.mail.MessagingException
public void sendMail(javax.mail.internet.InternetAddress sender, javax.mail.internet.InternetAddress recipient, String subject, String content, boolean isHTML) throws javax.mail.MessagingException
javax.mail.MessagingException
public void sendMail(javax.mail.internet.InternetAddress sender, javax.mail.internet.InternetAddress recipient, String subject, String content, boolean isHTML, DKIMBean dkim) throws javax.mail.MessagingException
javax.mail.MessagingException
public void sendMail(GlobalContext globalContext, javax.mail.internet.InternetAddress sender, javax.mail.internet.InternetAddress recipient, String subject, String content, boolean isHTML) throws javax.mail.MessagingException
javax.mail.MessagingException
public static void resetInstance()
public static String messageToText(javax.mail.internet.MimeMultipart part) throws IOException, javax.mail.MessagingException
IOException
javax.mail.MessagingException
public static String messageToDKIMBody(javax.mail.internet.MimeMultipart msg, OutputStream out) throws IOException, javax.mail.MessagingException
IOException
javax.mail.MessagingException
public static String _messageToDKIMBody(javax.mail.internet.MimeMultipart part) throws IOException, javax.mail.MessagingException
IOException
javax.mail.MessagingException
public static void writeEMLFile(String subject, String body, OutputStream out) throws javax.mail.MessagingException, IOException
javax.mail.MessagingException
IOException
public static void main(String[] args) throws FileNotFoundException, javax.mail.MessagingException, IOException
FileNotFoundException
javax.mail.MessagingException
IOException
Copyright © 2012-2018. All Rights Reserved.