public abstract class Email extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
ATTACHMENTS |
protected javax.mail.Authenticator |
authenticator
Instance of an
Authenticator object that will be used
when authentication is requested from the mail server. |
protected ArrayList |
bccList
List of "bcc" email adresses
|
protected String |
bounceAddress
Address to which undeliverable mail should be sent.
|
protected ArrayList |
ccList
List of "cc" email adresses
|
protected String |
charset
The charset to use for this message
|
protected Object |
content
The content
|
static String |
CONTENT_TYPE |
protected String |
contentType
The content type
|
protected boolean |
debug
Set session debugging on or off
|
static String |
EMAIL_BODY |
static String |
EMAIL_SUBJECT |
protected javax.mail.internet.MimeMultipart |
emailBody
An attachment
|
static String |
FILE_SERVER |
protected javax.mail.internet.InternetAddress |
fromAddress
The Address of the sending party, mandatory
|
protected Hashtable |
headers
Used to specify the mail headers.
|
protected String |
hostName
The hostname of the mail server with which to connect.
|
static String |
ISO_8859_1 |
static String |
KOI8_R |
static String |
MAIL_DEBUG |
static String |
MAIL_HOST |
static String |
MAIL_PORT |
static String |
MAIL_SMTP_AUTH |
static String |
MAIL_SMTP_FROM |
static String |
MAIL_TRANSPORT_PROTOCOL |
protected javax.mail.internet.MimeMessage |
message
The email message to send.
|
protected boolean |
popBeforeSmtp |
protected String |
popHost |
protected String |
popPassword |
protected String |
popUsername |
static String |
RECEIVER_EMAIL |
static String |
RECEIVER_NAME |
protected ArrayList |
replyList
List of "replyTo" email adresses
|
static String |
SENDER_EMAIL |
static String |
SENDER_NAME |
protected Date |
sentDate
Sent date
|
static String |
SMTP |
protected String |
smtpPort
The port number of the mail server to connect to.
|
protected String |
subject
The Subject
|
static String |
TEXT_HTML |
static String |
TEXT_PLAIN |
protected ArrayList |
toList
List of "to" email adresses
|
static String |
US_ASCII |
| Constructor and Description |
|---|
Email() |
| Modifier and Type | Method and Description |
|---|---|
Email |
addBcc(String email)
Add a blind BCC recipient to the email.
|
Email |
addBcc(String email,
String name)
Add a blind BCC recipient to the email.
|
Email |
addCc(String email)
Add a recipient CC to the email.
|
Email |
addCc(String email,
String name)
Add a recipient CC to the email.
|
void |
addHeader(String name,
String value)
Adds a header ( name, value ) to the headers Hashtable.
|
Email |
addReplyTo(String email)
Add a reply to address to the email.
|
Email |
addReplyTo(String email,
String name)
Add a reply to address to the email.
|
Email |
addTo(String email)
Add a recipient TO to the email.
|
Email |
addTo(String email,
String name)
Add a recipient TO to the email.
|
protected javax.mail.Session |
getMailSession()
Initialise a mailsession object
|
Date |
getSentDate()
Gets the sent date for the email.
|
void |
send()
Does the work of actually sending the email.
|
void |
setAuthentication(String userName,
String password)
Sets the userName and password if authentication is needed.
|
void |
setAuthenticator(javax.mail.Authenticator newAuthenticator)
Sets the
Authenticator to be used when authentication
is requested from the mail server. |
Email |
setBcc(Collection aCollection)
Set a list of "BCC" addresses
|
Email |
setBounceAddress(String email)
Set the "bounce address" - the address to which undeliverable messages
will be returned.
|
Email |
setCc(Collection aCollection)
Set a list of "CC" addresses
|
void |
setCharset(String newCharset)
Set the charset of the message.
|
void |
setContent(javax.mail.internet.MimeMultipart aMimeMultipart)
Set the emailBody to a MimeMultiPart
|
void |
setContent(Object aObject,
String aContentType)
Set the content & contentType
|
void |
setDebug(boolean d)
Setting to true will enable the display of debug information.
|
Email |
setFrom(String email)
Set the FROM field of the email.
|
Email |
setFrom(String email,
String name)
Set the FROM field of the email.
|
void |
setHeaders(Hashtable ht)
Used to specify the mail headers.
|
void |
setHostName(String aHostName)
Set the hostname of the outgoing mail server
|
void |
setMailSession(javax.mail.Session aSession)
Supply a mail Session object to use
|
abstract Email |
setMsg(String msg)
Define the content of the mail.
|
void |
setPopBeforeSmtp(boolean newPopBeforeSmtp,
String newPopHost,
String newPopUsername,
String newPopPassword)
Set details regarding "pop3 before smtp" authentication
|
void |
setSentDate(Date date)
Sets the sent date for the email.
|
void |
setSmtpPort(int aPortNumber)
Set the port number of the outgoing mail server.
|
Email |
setSubject(String aSubject)
Set the email subject.
|
Email |
setTo(Collection aCollection)
Set a list of "TO" addresses
|
protected javax.mail.internet.InternetAddress[] |
toInternetAddressArray(ArrayList aList)
Utility to copy ArrayList of known InternetAddress objects into an
array.
|
public static final String SENDER_EMAIL
public static final String SENDER_NAME
public static final String RECEIVER_EMAIL
public static final String RECEIVER_NAME
public static final String EMAIL_SUBJECT
public static final String EMAIL_BODY
public static final String CONTENT_TYPE
public static final String MAIL_HOST
public static final String MAIL_PORT
public static final String MAIL_SMTP_FROM
public static final String MAIL_SMTP_AUTH
public static final String MAIL_TRANSPORT_PROTOCOL
public static final String SMTP
public static final String TEXT_HTML
public static final String TEXT_PLAIN
public static final String ATTACHMENTS
public static final String FILE_SERVER
public static final String MAIL_DEBUG
public static final String KOI8_R
public static final String ISO_8859_1
public static final String US_ASCII
protected javax.mail.internet.MimeMessage message
protected String charset
protected javax.mail.internet.InternetAddress fromAddress
protected String subject
protected javax.mail.internet.MimeMultipart emailBody
protected Object content
protected String contentType
protected boolean debug
protected Date sentDate
protected javax.mail.Authenticator authenticator
Authenticator object that will be used
when authentication is requested from the mail server.protected String hostName
protected String smtpPort
protected ArrayList toList
protected ArrayList ccList
protected ArrayList bccList
protected ArrayList replyList
protected String bounceAddress
String
rather than InternetAddress.protected Hashtable headers
protected boolean popBeforeSmtp
protected String popHost
protected String popUsername
protected String popPassword
public void setDebug(boolean d)
d - A boolean.public void setAuthentication(String userName, 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(javax.mail.Authenticator)public void setAuthenticator(javax.mail.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.Authenticatorpublic void setCharset(String newCharset)
newCharset - A String.public void setContent(javax.mail.internet.MimeMultipart aMimeMultipart)
aMimeMultipart - aMimeMultipartpublic void setContent(Object aObject, String aContentType)
aObject - aObjectaContentType - aContentTypepublic void setHostName(String aHostName)
aHostName - aHostNamepublic void setSmtpPort(int aPortNumber)
aPortNumber - aPortNumberpublic void setMailSession(javax.mail.Session aSession)
aSession - mail session to be usedprotected javax.mail.Session getMailSession()
throws javax.mail.MessagingException
javax.mail.MessagingException - thrown when host name was not setpublic Email setFrom(String email) throws javax.mail.MessagingException
email - A String.javax.mail.MessagingException - Indicates an invalid email addresspublic Email setFrom(String email, String name) throws javax.mail.MessagingException
email - A String.name - A String.javax.mail.MessagingException - Indicates an invalid email addresspublic Email addTo(String email) throws javax.mail.MessagingException
email - A String.javax.mail.MessagingException - Indicates an invalid email addresspublic Email addTo(String email, String name) throws javax.mail.MessagingException
email - A String.name - A String.javax.mail.MessagingException - Indicates an invalid email addresspublic Email setTo(Collection aCollection) throws javax.mail.MessagingException
aCollection - collection of InternetAddress objectsjavax.mail.MessagingException - Indicates an invalid email addresspublic Email addCc(String email) throws javax.mail.MessagingException
email - A String.javax.mail.MessagingException - Indicates an invalid email addresspublic Email addCc(String email, String name) throws javax.mail.MessagingException
email - A String.name - A String.javax.mail.MessagingException - Indicates an invalid email addresspublic Email setCc(Collection aCollection) throws javax.mail.MessagingException
aCollection - collection of InternetAddress objectsjavax.mail.MessagingException - Indicates an invalid email addresspublic Email addBcc(String email) throws javax.mail.MessagingException
email - A String.javax.mail.MessagingException - Indicates an invalid email addresspublic Email addBcc(String email, String name) throws javax.mail.MessagingException
email - A String.name - A String.javax.mail.MessagingException - Indicates an invalid email addresspublic Email setBcc(Collection aCollection) throws javax.mail.MessagingException
aCollection - collection of InternetAddress objectsjavax.mail.MessagingException - Indicates an invalid email addresspublic Email addReplyTo(String email) throws javax.mail.MessagingException
email - A String.javax.mail.MessagingException - Indicates an invalid email addresspublic Email addReplyTo(String email, String name) throws javax.mail.MessagingException
email - A String.name - A String.javax.mail.MessagingException - Indicates an invalid email addresspublic void setHeaders(Hashtable ht)
ht - A Hashtable.public void addHeader(String name, String value)
name - A String with the name.value - A String with the value.public Email setSubject(String aSubject)
aSubject - A String.public Email setBounceAddress(String email)
email - A String.public abstract Email setMsg(String msg) throws javax.mail.MessagingException
msg - A String.javax.mail.MessagingException - generic exceptionpublic void send()
throws javax.mail.MessagingException
javax.mail.MessagingException - if there was an error.public void setSentDate(Date date)
date - Date to use as the sent date on the emailpublic Date getSentDate()
protected javax.mail.internet.InternetAddress[] toInternetAddressArray(ArrayList aList)
aList - A ArrayList.public void setPopBeforeSmtp(boolean newPopBeforeSmtp,
String newPopHost,
String newPopUsername,
String newPopPassword)
newPopBeforeSmtp - Wether or not to log into pop3
server before sending mailnewPopHost - The pop3 host to use.newPopUsername - The pop3 username.newPopPassword - The pop3 password.Copyright © 2020 B3Partners B.V.. All rights reserved.