public class Mailer extends Object
Modifier and Type | Class and Description |
---|---|
static class |
Mailer.Message |
Modifier and Type | Field and Description |
---|---|
protected javax.mail.Authenticator |
auth |
protected Properties |
config |
protected javax.mail.Session |
session |
protected String |
sessionName
The JNDI session name.
|
Constructor and Description |
---|
Mailer()
Create a mailer that can be configured using the API.
|
Mailer(Properties config)
Create a mailer that use the given properties to configure the session.
|
Mailer(String sessionName)
Create a mailer using a session that lookup for the session in JNDI under the given session name.
|
Mailer(String sessionName,
Properties config)
Create a mailer using a session that lookup for the session in JNDI under the given session name.
|
Modifier and Type | Method and Description |
---|---|
Properties |
getConfiguration() |
javax.mail.Session |
getSession() |
void |
loadConfiguration(InputStream in) |
Mailer.Message |
newMessage() |
void |
send(javax.mail.internet.MimeMessage message) |
void |
sendEmail(String from,
String to,
String subject,
String body)
Send a single email.
|
void |
setAuthenticator(javax.mail.Authenticator auth) |
void |
setConfiguration(Properties config) |
void |
setCredentials(String user,
String pass)
Set SMTP credential
|
void |
setDebug(boolean debug) |
void |
setServer(String host) |
void |
setServer(String host,
boolean ssl) |
void |
setServer(String host,
String port)
Set the SMTP server address to use
|
void |
setServer(String host,
String port,
boolean ssl) |
protected Properties config
protected volatile javax.mail.Session session
protected javax.mail.Authenticator auth
protected final String sessionName
config
) will be used to create a session.public Mailer()
public Mailer(Properties config)
config
- public Mailer(String sessionName)
sessionName
- public Mailer(String sessionName, Properties config)
sessionName
- config
- public void setServer(String host, String port)
host
- port
- public void setCredentials(String user, String pass)
user
- pass
- public void setAuthenticator(javax.mail.Authenticator auth)
public void setDebug(boolean debug)
public javax.mail.Session getSession()
public Properties getConfiguration()
public void setConfiguration(Properties config)
public void loadConfiguration(InputStream in) throws IOException
IOException
public void send(javax.mail.internet.MimeMessage message) throws javax.mail.MessagingException
javax.mail.MessagingException
public Mailer.Message newMessage()
Copyright © 2015 Nuxeo SA. All rights reserved.