public abstract class Email
extends java.lang.Object
Subclasses are responsible for setting the message body.
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
ATTACHMENTS
Deprecated.
since 1.3, use
EmailConstants.ATTACHMENTS instead |
static java.lang.String |
CONTENT_TYPE
Deprecated.
since 1.3, use
EmailConstants.CONTENT_TYPE instead |
static java.lang.String |
EMAIL_BODY
Deprecated.
since 1.3, use
EmailConstants.EMAIL_BODY instead |
static java.lang.String |
EMAIL_SUBJECT
Deprecated.
since 1.3, use
EmailConstants.EMAIL_SUBJECT instead |
static java.lang.String |
FILE_SERVER
Deprecated.
since 1.3, use
EmailConstants.FILE_SERVER instead |
static java.lang.String |
ISO_8859_1
Deprecated.
since 1.3, use
EmailConstants.ISO_8859_1 instead |
static java.lang.String |
KOI8_R
Deprecated.
since 1.3, use
EmailConstants.KOI8_R instead |
static java.lang.String |
MAIL_DEBUG
Deprecated.
since 1.3, use
EmailConstants.MAIL_DEBUG instead |
static java.lang.String |
MAIL_HOST
Deprecated.
since 1.3, use
EmailConstants.MAIL_HOST instead |
static java.lang.String |
MAIL_PORT
Deprecated.
since 1.3, use
EmailConstants.MAIL_PORT instead |
static java.lang.String |
MAIL_SMTP_AUTH
Deprecated.
since 1.3, use
EmailConstants.MAIL_SMTP_AUTH instead |
static java.lang.String |
MAIL_SMTP_CONNECTIONTIMEOUT
Deprecated.
since 1.3, use
EmailConstants.MAIL_SMTP_CONNECTIONTIMEOUT instead |
static java.lang.String |
MAIL_SMTP_FROM
Deprecated.
since 1.3, use
EmailConstants.MAIL_SMTP_FROM instead |
static java.lang.String |
MAIL_SMTP_PASSWORD
Deprecated.
since 1.3, use
EmailConstants.MAIL_SMTP_PASSWORD instead |
static java.lang.String |
MAIL_SMTP_SOCKET_FACTORY_CLASS
Deprecated.
since 1.3, use
EmailConstants.MAIL_SMTP_SOCKET_FACTORY_CLASS instead |
static java.lang.String |
MAIL_SMTP_SOCKET_FACTORY_FALLBACK
Deprecated.
since 1.3, use
EmailConstants.MAIL_SMTP_SOCKET_FACTORY_FALLBACK instead |
static java.lang.String |
MAIL_SMTP_SOCKET_FACTORY_PORT
Deprecated.
since 1.3, use
EmailConstants.MAIL_SMTP_SOCKET_FACTORY_PORT instead |
static java.lang.String |
MAIL_SMTP_TIMEOUT
Deprecated.
since 1.3, use
EmailConstants.MAIL_SMTP_TIMEOUT instead |
static java.lang.String |
MAIL_SMTP_USER
Deprecated.
since 1.3, use
EmailConstants.MAIL_SMTP_USER instead |
static java.lang.String |
MAIL_TRANSPORT_PROTOCOL
Deprecated.
since 1.3, use
EmailConstants.MAIL_TRANSPORT_PROTOCOL instead |
static java.lang.String |
MAIL_TRANSPORT_TLS
Deprecated.
since 1.3, use
EmailConstants.MAIL_TRANSPORT_TLS instead |
static java.lang.String |
RECEIVER_EMAIL
Deprecated.
since 1.3, use
EmailConstants.RECEIVER_EMAIL instead |
static java.lang.String |
RECEIVER_NAME
Deprecated.
since 1.3, use
EmailConstants.RECEIVER_NAME instead |
static java.lang.String |
SENDER_EMAIL
Deprecated.
since 1.3, use
EmailConstants.SENDER_EMAIL instead |
static java.lang.String |
SENDER_NAME
Deprecated.
since 1.3, use
EmailConstants.SENDER_NAME instead |
static java.lang.String |
SMTP
Deprecated.
since 1.3, use
EmailConstants.SMTP instead |
static java.lang.String |
TEXT_HTML
Deprecated.
since 1.3, use
EmailConstants.TEXT_HTML instead |
static java.lang.String |
TEXT_PLAIN
Deprecated.
since 1.3, use
EmailConstants.TEXT_PLAIN instead |
static java.lang.String |
US_ASCII
Deprecated.
since 1.3, use
EmailConstants.US_ASCII instead |
Constructor and Description |
---|
Email() |
Modifier and Type | Method and Description |
---|---|
Email |
addBcc(java.lang.String... emails)
Add an array of blind BCC recipients to the email.
|
Email |
addBcc(java.lang.String email)
Add a blind BCC recipient to the email.
|
Email |
addBcc(java.lang.String email,
java.lang.String name)
Add a blind BCC recipient to the email using the specified address and
the specified personal name.
|
Email |
addBcc(java.lang.String email,
java.lang.String name,
java.lang.String charset)
Add a blind BCC recipient to the email using the specified address,
personal name, and charset encoding for the name.
|
Email |
addCc(java.lang.String... emails)
Add an array of CC recipients to the email.
|
Email |
addCc(java.lang.String email)
Add a recipient CC to the email.
|
Email |
addCc(java.lang.String email,
java.lang.String name)
Add a recipient CC to the email using the specified address and the
specified personal name.
|
Email |
addCc(java.lang.String email,
java.lang.String name,
java.lang.String charset)
Add a recipient CC to the email using the specified address, personal
name, and charset encoding for the name.
|
void |
addHeader(java.lang.String name,
java.lang.String value)
Adds a header ( name, value ) to the headers Map.
|
Email |
addReplyTo(java.lang.String email)
Add a reply to address to the email.
|
Email |
addReplyTo(java.lang.String email,
java.lang.String name)
Add a reply to address to the email using the specified address and
the specified personal name.
|
Email |
addReplyTo(java.lang.String email,
java.lang.String name,
java.lang.String charset)
Add a reply to address to the email using the specified address,
personal name, and charset encoding for the name.
|
Email |
addTo(java.lang.String... emails)
Add a list of TO recipients to the email.
|
Email |
addTo(java.lang.String email)
Add a recipient TO to the email.
|
Email |
addTo(java.lang.String email,
java.lang.String name)
Add a recipient TO to the email using the specified address and the
specified personal name.
|
Email |
addTo(java.lang.String email,
java.lang.String name,
java.lang.String charset)
Add a recipient TO to the email using the specified address, personal
name, and charset encoding for the name.
|
void |
buildMimeMessage()
Does the work of actually building the MimeMessage.
|
java.util.List<InternetAddress> |
getBccAddresses()
Get the list of "Bcc" addresses.
|
java.lang.String |
getBounceAddress()
Gets the "bounce address" of this email.
|
java.util.List<InternetAddress> |
getCcAddresses()
Get the list of "CC" addresses.
|
InternetAddress |
getFromAddress()
Gets the sender of the email.
|
java.lang.String |
getHeader(java.lang.String header)
Gets the specified header.
|
java.util.Map<java.lang.String,java.lang.String> |
getHeaders()
Gets all headers on an Email.
|
java.lang.String |
getHostName()
Gets the host name of the SMTP server,
|
Session |
getMailSession()
Determines the mail session used when sending this Email, creating
the Session if necessary.
|
MimeMessage |
getMimeMessage()
Returns the internal MimeMessage.
|
java.util.List<InternetAddress> |
getReplyToAddresses()
Get the list of "Reply-To" addresses.
|
java.util.Date |
getSentDate()
Gets the sent date for the email.
|
java.lang.String |
getSmtpPort()
Gets the listening port of the SMTP server.
|
int |
getSocketConnectionTimeout()
Get the socket connection timeout value in milliseconds.
|
int |
getSocketTimeout()
Get the socket I/O timeout value in milliseconds.
|
java.lang.String |
getSslSmtpPort()
Returns the current SSL port used by the SMTP transport.
|
java.lang.String |
getSubject()
Gets the subject of the email.
|
java.util.List<InternetAddress> |
getToAddresses()
Get the list of "To" addresses.
|
boolean |
isSendPartial()
If partial sending of email enabled.
|
boolean |
isSSL()
Deprecated.
since 1.3, use isSSLOnConnect() instead
|
boolean |
isSSLCheckServerIdentity()
Is the server identity checked as specified by RFC 2595
|
boolean |
isSSLOnConnect()
Returns whether SSL/TLS encryption for the transport is currently enabled (SMTPS/POPS).
|
boolean |
isStartTLSEnabled()
Gets whether the client is configured to try to enable STARTTLS.
|
boolean |
isStartTLSRequired()
Gets whether the client is configured to require STARTTLS.
|
boolean |
isTLS()
Deprecated.
since 1.3, use isStartTLSEnabled() instead
|
java.lang.String |
send()
Sends the email.
|
java.lang.String |
sendMimeMessage()
Sends the previously created MimeMessage to the SMTP server.
|
void |
setAuthentication(java.lang.String userName,
java.lang.String password)
Sets the userName and password if authentication is needed.
|
void |
setAuthenticator(Authenticator newAuthenticator)
Sets the
Authenticator to be used when authentication
is requested from the mail server. |
Email |
setBcc(java.util.Collection<InternetAddress> aCollection)
Set a list of "BCC" addresses.
|
Email |
setBounceAddress(java.lang.String email)
Set the "bounce address" - the address to which undeliverable messages
will be returned.
|
Email |
setCc(java.util.Collection<InternetAddress> aCollection)
Set a list of "CC" addresses.
|
void |
setCharset(java.lang.String newCharset)
Set the charset of the message.
|
void |
setContent(MimeMultipart aMimeMultipart)
Set the emailBody to a MimeMultiPart
|
void |
setContent(java.lang.Object aObject,
java.lang.String aContentType)
Set the content and contentType.
|
void |
setDebug(boolean d)
Setting to true will enable the display of debug information.
|
Email |
setFrom(java.lang.String email)
Set the FROM field of the email to use the specified address.
|
Email |
setFrom(java.lang.String email,
java.lang.String name)
Set the FROM field of the email to use the specified address and the
specified personal name.
|
Email |
setFrom(java.lang.String email,
java.lang.String name,
java.lang.String charset)
Set the FROM field of the email to use the specified address, personal
name, and charset encoding for the name.
|
void |
setHeaders(java.util.Map<java.lang.String,java.lang.String> map)
Used to specify the mail headers.
|
void |
setHostName(java.lang.String aHostName)
Set the hostname of the outgoing mail server.
|
void |
setMailSession(Session aSession)
Supply a mail Session object to use.
|
void |
setMailSessionFromJNDI(java.lang.String jndiName)
Supply a mail Session object from a JNDI directory.
|
abstract Email |
setMsg(java.lang.String msg)
Define the content of the mail.
|
void |
setPopBeforeSmtp(boolean newPopBeforeSmtp,
java.lang.String newPopHost,
java.lang.String newPopUsername,
java.lang.String newPopPassword)
Set details regarding "pop3 before smtp" authentication.
|
Email |
setReplyTo(java.util.Collection<InternetAddress> aCollection)
Set a list of reply to addresses.
|
Email |
setSendPartial(boolean sendPartial)
Sets whether the email is partially send in case of invalid addresses.
|
void |
setSentDate(java.util.Date date)
Sets the sent date for the email.
|
void |
setSmtpPort(int aPortNumber)
Set the non-SSL port number of the outgoing mail server.
|
void |
setSocketConnectionTimeout(int socketConnectionTimeout)
Set the socket connection timeout value in milliseconds.
|
void |
setSocketTimeout(int socketTimeout)
Set the socket I/O timeout value in milliseconds.
|
void |
setSSL(boolean ssl)
Deprecated.
since 1.3, use setSSLOnConnect() instead
|
Email |
setSSLCheckServerIdentity(boolean sslCheckServerIdentity)
Sets whether the server identity is checked as specified by RFC 2595
|
Email |
setSSLOnConnect(boolean ssl)
Sets whether SSL/TLS encryption should be enabled for the SMTP transport upon connection (SMTPS/POPS).
|
void |
setSslSmtpPort(java.lang.String sslSmtpPort)
Sets the SSL port to use for the SMTP transport.
|
Email |
setStartTLSEnabled(boolean startTlsEnabled)
Set or disable the STARTTLS encryption.
|
Email |
setStartTLSRequired(boolean startTlsRequired)
Set or disable the required STARTTLS encryption.
|
Email |
setSubject(java.lang.String aSubject)
Sets the email subject.
|
void |
setTLS(boolean withTLS)
Deprecated.
since 1.3, use setStartTLSEnabled() instead
|
Email |
setTo(java.util.Collection<InternetAddress> aCollection)
Set a list of "TO" addresses.
|
void |
updateContentType(java.lang.String aContentType)
Update the contentType.
|
@Deprecated public static final java.lang.String SENDER_EMAIL
EmailConstants.SENDER_EMAIL
instead@Deprecated public static final java.lang.String SENDER_NAME
EmailConstants.SENDER_NAME
instead@Deprecated public static final java.lang.String RECEIVER_EMAIL
EmailConstants.RECEIVER_EMAIL
instead@Deprecated public static final java.lang.String RECEIVER_NAME
EmailConstants.RECEIVER_NAME
instead@Deprecated public static final java.lang.String EMAIL_SUBJECT
EmailConstants.EMAIL_SUBJECT
instead@Deprecated public static final java.lang.String EMAIL_BODY
EmailConstants.EMAIL_BODY
instead@Deprecated public static final java.lang.String CONTENT_TYPE
EmailConstants.CONTENT_TYPE
instead@Deprecated public static final java.lang.String ATTACHMENTS
EmailConstants.ATTACHMENTS
instead@Deprecated public static final java.lang.String FILE_SERVER
EmailConstants.FILE_SERVER
instead@Deprecated public static final java.lang.String KOI8_R
EmailConstants.KOI8_R
instead@Deprecated public static final java.lang.String ISO_8859_1
EmailConstants.ISO_8859_1
instead@Deprecated public static final java.lang.String US_ASCII
EmailConstants.US_ASCII
instead@Deprecated public static final java.lang.String MAIL_DEBUG
EmailConstants.MAIL_DEBUG
instead@Deprecated public static final java.lang.String MAIL_HOST
EmailConstants.MAIL_HOST
instead@Deprecated public static final java.lang.String MAIL_PORT
EmailConstants.MAIL_PORT
instead@Deprecated public static final java.lang.String MAIL_SMTP_FROM
EmailConstants.MAIL_SMTP_FROM
instead@Deprecated public static final java.lang.String MAIL_SMTP_AUTH
EmailConstants.MAIL_SMTP_AUTH
instead@Deprecated public static final java.lang.String MAIL_SMTP_USER
EmailConstants.MAIL_SMTP_USER
instead@Deprecated public static final java.lang.String MAIL_SMTP_PASSWORD
EmailConstants.MAIL_SMTP_PASSWORD
instead@Deprecated public static final java.lang.String MAIL_TRANSPORT_PROTOCOL
EmailConstants.MAIL_TRANSPORT_PROTOCOL
instead@Deprecated public static final java.lang.String SMTP
EmailConstants.SMTP
instead@Deprecated public static final java.lang.String TEXT_HTML
EmailConstants.TEXT_HTML
instead@Deprecated public static final java.lang.String TEXT_PLAIN
EmailConstants.TEXT_PLAIN
instead@Deprecated public static final java.lang.String MAIL_TRANSPORT_TLS
EmailConstants.MAIL_TRANSPORT_TLS
instead@Deprecated public static final java.lang.String MAIL_SMTP_SOCKET_FACTORY_FALLBACK
EmailConstants.MAIL_SMTP_SOCKET_FACTORY_FALLBACK
instead@Deprecated public static final java.lang.String MAIL_SMTP_SOCKET_FACTORY_CLASS
EmailConstants.MAIL_SMTP_SOCKET_FACTORY_CLASS
instead@Deprecated public static final java.lang.String MAIL_SMTP_SOCKET_FACTORY_PORT
EmailConstants.MAIL_SMTP_SOCKET_FACTORY_PORT
instead@Deprecated public static final java.lang.String MAIL_SMTP_CONNECTIONTIMEOUT
EmailConstants.MAIL_SMTP_CONNECTIONTIMEOUT
instead@Deprecated public static final java.lang.String MAIL_SMTP_TIMEOUT
EmailConstants.MAIL_SMTP_TIMEOUT
insteadpublic void setDebug(boolean d)
d
- A boolean.public void setAuthentication(java.lang.String userName, java.lang.String password)
This method will create a new instance of
DefaultAuthenticator
using the supplied parameters.
userName
- User name for the SMTP serverpassword
- password for the SMTP serverDefaultAuthenticator
,
setAuthenticator(Authenticator)
public void setAuthenticator(Authenticator newAuthenticator)
Authenticator
to be used when authentication
is requested from the mail server.
This method should be used when your outgoing mail server requires authentication. Your mail server must also support RFC2554.
newAuthenticator
- the Authenticator
object.Authenticator
public void setCharset(java.lang.String newCharset)
newCharset
- A String.java.nio.charset.IllegalCharsetNameException
- if the charset name is invalidjava.nio.charset.UnsupportedCharsetException
- if no support for the named charset
exists in the current JVMpublic void setContent(MimeMultipart aMimeMultipart)
aMimeMultipart
- aMimeMultipartpublic void setContent(java.lang.Object aObject, java.lang.String aContentType)
aObject
- aObjectaContentType
- aContentTypepublic void updateContentType(java.lang.String aContentType)
aContentType
- aContentTypepublic void setHostName(java.lang.String aHostName)
aHostName
- aHostNamejava.lang.IllegalStateException
- if the mail session is already initialized@Deprecated public void setTLS(boolean withTLS)
withTLS
- true if STARTTLS requested, false otherwisepublic Email setStartTLSEnabled(boolean startTlsEnabled)
startTlsEnabled
- true if STARTTLS requested, false otherwisejava.lang.IllegalStateException
- if the mail session is already initializedpublic Email setStartTLSRequired(boolean startTlsRequired)
Defaults to smtpPort
; can be overridden by using setSmtpPort(int)
startTlsRequired
- true if STARTTLS requested, false otherwisejava.lang.IllegalStateException
- if the mail session is already initializedpublic void setSmtpPort(int aPortNumber)
aPortNumber
- aPortNumberjava.lang.IllegalArgumentException
- if the port number is < 1java.lang.IllegalStateException
- if the mail session is already initializedsetSslSmtpPort(String)
public void setMailSession(Session aSession)
aSession
- mail session to be usedjava.lang.IllegalArgumentException
- if the session is null
public void setMailSessionFromJNDI(java.lang.String jndiName) throws javax.naming.NamingException
jndiName
- name of JNDI resource (javax.mail.Session type), resource
if searched in java:comp/env if name does not start with "java:"java.lang.IllegalArgumentException
- if the JNDI name is null or emptyjavax.naming.NamingException
- if the resource cannot be retrieved from JNDI directorypublic Session getMailSession() throws EmailException
EmailException
- if the host name was not setpublic Email setFrom(java.lang.String email) throws EmailException
setCharset()
.
If it is not set, it will be encoded using
the Java platform's default charset (UTF-16) if it contains
non-ASCII characters; otherwise, it is used as is.email
- A String.EmailException
- Indicates an invalid email address.public Email setFrom(java.lang.String email, java.lang.String name) throws EmailException
setCharset()
.
If it is not set, it will be encoded using
the Java platform's default charset (UTF-16) if it contains
non-ASCII characters; otherwise, it is used as is.email
- A String.name
- A String.EmailException
- Indicates an invalid email address.public Email setFrom(java.lang.String email, java.lang.String name, java.lang.String charset) throws EmailException
email
- A String.name
- A String.charset
- The charset to encode the name with.EmailException
- Indicates an invalid email address or charset.public Email addTo(java.lang.String email) throws EmailException
setCharset()
.
If it is not set, it will be encoded using
the Java platform's default charset (UTF-16) if it contains
non-ASCII characters; otherwise, it is used as is.email
- A String.EmailException
- Indicates an invalid email address.public Email addTo(java.lang.String... emails) throws EmailException
setCharset()
.
If it is not set, it will be encoded using
the Java platform's default charset (UTF-16) if it contains
non-ASCII characters; otherwise, it is used as is.emails
- A String array.EmailException
- Indicates an invalid email address.public Email addTo(java.lang.String email, java.lang.String name) throws EmailException
setCharset()
.
If it is not set, it will be encoded using
the Java platform's default charset (UTF-16) if it contains
non-ASCII characters; otherwise, it is used as is.email
- A String.name
- A String.EmailException
- Indicates an invalid email address.public Email addTo(java.lang.String email, java.lang.String name, java.lang.String charset) throws EmailException
email
- A String.name
- A String.charset
- The charset to encode the name with.EmailException
- Indicates an invalid email address or charset.public Email setTo(java.util.Collection<InternetAddress> aCollection) throws EmailException
Collection
are expected to be of type
java.mail.internet.InternetAddress
.aCollection
- collection of InternetAddress
objects.EmailException
- Indicates an invalid email address.javax.mail.internet.InternetAddress
public Email addCc(java.lang.String email) throws EmailException
setCharset()
.
If it is not set, it will be encoded using
the Java platform's default charset (UTF-16) if it contains
non-ASCII characters; otherwise, it is used as is.email
- A String.EmailException
- Indicates an invalid email address.public Email addCc(java.lang.String... emails) throws EmailException
setCharset()
.
If it is not set, it will be encoded using
the Java platform's default charset (UTF-16) if it contains
non-ASCII characters; otherwise, it is used as is.emails
- A String array.EmailException
- Indicates an invalid email address.public Email addCc(java.lang.String email, java.lang.String name) throws EmailException
setCharset()
.
If it is not set, it will be encoded using
the Java platform's default charset (UTF-16) if it contains
non-ASCII characters; otherwise, it is used as is.email
- A String.name
- A String.EmailException
- Indicates an invalid email address.public Email addCc(java.lang.String email, java.lang.String name, java.lang.String charset) throws EmailException
email
- A String.name
- A String.charset
- The charset to encode the name with.EmailException
- Indicates an invalid email address or charset.public Email setCc(java.util.Collection<InternetAddress> aCollection) throws EmailException
Collection
are expected to be of type
java.mail.internet.InternetAddress
.aCollection
- collection of InternetAddress
objects.EmailException
- Indicates an invalid email address.javax.mail.internet.InternetAddress
public Email addBcc(java.lang.String email) throws EmailException
setCharset()
.
If it is not set, it will be encoded using
the Java platform's default charset (UTF-16) if it contains
non-ASCII characters; otherwise, it is used as is.email
- A String.EmailException
- Indicates an invalid email addresspublic Email addBcc(java.lang.String... emails) throws EmailException
setCharset()
.
If it is not set, it will be encoded using
the Java platform's default charset (UTF-16) if it contains
non-ASCII characters; otherwise, it is used as is.emails
- A String array.EmailException
- Indicates an invalid email addresspublic Email addBcc(java.lang.String email, java.lang.String name) throws EmailException
setCharset()
.
If it is not set, it will be encoded using
the Java platform's default charset (UTF-16) if it contains
non-ASCII characters; otherwise, it is used as is.email
- A String.name
- A String.EmailException
- Indicates an invalid email addresspublic Email addBcc(java.lang.String email, java.lang.String name, java.lang.String charset) throws EmailException
email
- A String.name
- A String.charset
- The charset to encode the name with.EmailException
- Indicates an invalid email addresspublic Email setBcc(java.util.Collection<InternetAddress> aCollection) throws EmailException
Collection
are expected to be of type
java.mail.internet.InternetAddress
.aCollection
- collection of InternetAddress
objectsEmailException
- Indicates an invalid email addressjavax.mail.internet.InternetAddress
public Email addReplyTo(java.lang.String email) throws EmailException
setCharset()
.
If it is not set, it will be encoded using
the Java platform's default charset (UTF-16) if it contains
non-ASCII characters; otherwise, it is used as is.email
- A String.EmailException
- Indicates an invalid email addresspublic Email addReplyTo(java.lang.String email, java.lang.String name) throws EmailException
setCharset()
.
If it is not set, it will be encoded using
the Java platform's default charset (UTF-16) if it contains
non-ASCII characters; otherwise, it is used as is.email
- A String.name
- A String.EmailException
- Indicates an invalid email addresspublic Email addReplyTo(java.lang.String email, java.lang.String name, java.lang.String charset) throws EmailException
email
- A String.name
- A String.charset
- The charset to encode the name with.EmailException
- Indicates an invalid email address or charset.public Email setReplyTo(java.util.Collection<InternetAddress> aCollection) throws EmailException
Collection
are expected to be of type
java.mail.internet.InternetAddress
.aCollection
- collection of InternetAddress
objectsEmailException
- Indicates an invalid email addressjavax.mail.internet.InternetAddress
public void setHeaders(java.util.Map<java.lang.String,java.lang.String> map)
map
- A Map.java.lang.IllegalArgumentException
- if either of the provided header / value is null or emptypublic void addHeader(java.lang.String name, java.lang.String value)
name
- A String with the name.value
- A String with the value.java.lang.IllegalArgumentException
- if either name
or value
is null or emptypublic java.lang.String getHeader(java.lang.String header)
header
- A string with the header.public java.util.Map<java.lang.String,java.lang.String> getHeaders()
public Email setSubject(java.lang.String aSubject)
aSubject
- A String.public java.lang.String getBounceAddress()
public Email setBounceAddress(java.lang.String email)
email
- A String.java.lang.IllegalStateException
- if the mail session is already initializedpublic abstract Email setMsg(java.lang.String msg) throws EmailException
msg
- A String.EmailException
- generic exception.public void buildMimeMessage() throws EmailException
java.lang.IllegalStateException
- if the MimeMessage was already builtEmailException
- if there was an error.public java.lang.String sendMimeMessage() throws EmailException
java.lang.IllegalArgumentException
- if the MimeMessage has not been createdEmailException
- the sending failedpublic MimeMessage getMimeMessage()
public java.lang.String send() throws EmailException
java.lang.IllegalStateException
- if the MimeMessage was already built, ie buildMimeMessage()
was already calledEmailException
- the sending failedpublic void setSentDate(java.util.Date date)
date
- Date to use as the sent date on the emailpublic java.util.Date getSentDate()
public java.lang.String getSubject()
public InternetAddress getFromAddress()
public java.lang.String getHostName()
public java.lang.String getSmtpPort()
public boolean isStartTLSRequired()
public boolean isStartTLSEnabled()
@Deprecated public boolean isTLS()
public void setPopBeforeSmtp(boolean newPopBeforeSmtp, java.lang.String newPopHost, java.lang.String newPopUsername, java.lang.String newPopPassword)
newPopBeforeSmtp
- Whether or not to log into pop3 server before sending mail.newPopHost
- The pop3 host to use.newPopUsername
- The pop3 username.newPopPassword
- The pop3 password.@Deprecated public boolean isSSL()
public boolean isSSLOnConnect()
@Deprecated public void setSSL(boolean ssl)
ssl
- whether to enable the SSL transportpublic Email setSSLOnConnect(boolean ssl)
setStartTLSRequired(boolean)
Defaults to sslSmtpPort
; can be overridden by using setSslSmtpPort(String)
ssl
- whether to enable the SSL transportjava.lang.IllegalStateException
- if the mail session is already initializedpublic boolean isSSLCheckServerIdentity()
public Email setSSLCheckServerIdentity(boolean sslCheckServerIdentity)
sslCheckServerIdentity
- whether to enable server identity checkjava.lang.IllegalStateException
- if the mail session is already initializedpublic java.lang.String getSslSmtpPort()
public void setSslSmtpPort(java.lang.String sslSmtpPort)
sslSmtpPort
- the SSL port to use for the SMTP transportjava.lang.IllegalStateException
- if the mail session is already initializedsetSmtpPort(int)
public boolean isSendPartial()
public Email setSendPartial(boolean sendPartial)
In case the mail server rejects an address as invalid, the call to send()
may throw a javax.mail.SendFailedException
, even if partial send mode is enabled (emails
to valid addresses will be transmitted). In case the email server does not reject
invalid addresses immediately, but return a bounce message, no exception will be thrown
by the send()
method.
sendPartial
- whether to enable partial send modejava.lang.IllegalStateException
- if the mail session is already initializedpublic java.util.List<InternetAddress> getToAddresses()
public java.util.List<InternetAddress> getCcAddresses()
public java.util.List<InternetAddress> getBccAddresses()
public java.util.List<InternetAddress> getReplyToAddresses()
public int getSocketConnectionTimeout()
public void setSocketConnectionTimeout(int socketConnectionTimeout)
socketConnectionTimeout
- the connection timeoutjava.lang.IllegalStateException
- if the mail session is already initializedpublic int getSocketTimeout()
public void setSocketTimeout(int socketTimeout)
socketTimeout
- the socket I/O timeoutjava.lang.IllegalStateException
- if the mail session is already initialized"Copyright © 2010 - 2020 Adobe Systems Incorporated. All Rights Reserved"