public class SMTPConnection extends Object
Constructor and Description |
---|
SMTPConnection(String host,
String port,
boolean useAuthentication,
String secure,
String username,
String password,
String from)
Instantiates an SMTP connection used to send e-mail messages with.
|
SMTPConnection(String host,
String port,
int socketTimeout,
boolean useAuthentication,
String secure,
String username,
String password,
String from)
Instantiates an SMTP connection used to send e-mail messages with.
|
Modifier and Type | Method and Description |
---|---|
String |
getFrom()
Returns the FROM field being used for dispatched e-mail messages.
|
String |
getHost()
Returns the SMTP server address.
|
String |
getPassword()
Returns the password being used to authenticate to the SMTP server.
|
String |
getPort()
Returns the SMTP server port.
|
String |
getSecure()
Returns the encryption security layer being used for the SMTP connection (e.g "TLS" or
"SSL").
|
int |
getSocketTimeout()
Returns the socket connection timeout value in milliseconds.
|
String |
getUsername()
Returns the username being used to authenticate to the SMTP server.
|
boolean |
isUseAuthentication()
Returns true if authentication is needed for the SMTP server, otherwise returns false.
|
void |
send(String toList,
String ccList,
String subject,
String body)
Sends an e-mail message.
|
void |
send(String toList,
String ccList,
String from,
String subject,
String body)
Sends an e-mail message.
|
void |
send(String toList,
String ccList,
String from,
String subject,
String body,
String charset)
Sends an e-mail message.
|
void |
setFrom(String from)
Sets the FROM field to use for dispatched e-mail messages.
|
void |
setHost(String host)
Sets the SMTP server address.
|
void |
setPassword(String password)
Sets the password to use to authenticate to the SMTP server.
|
void |
setPort(String port)
Sets the SMTP server port.
|
void |
setSecure(String secure)
Sets the encryption security layer to use for the SMTP connection.
|
void |
setSocketTimeout(int socketTimeout)
Sets the socket connection timeout value.
|
void |
setUseAuthentication(boolean useAuthentication)
Sets whether authentication is needed for the SMTP server.
|
void |
setUsername(String username)
Sets the username to use to authenticate to the SMTP server.
|
public SMTPConnection(String host, String port, int socketTimeout, boolean useAuthentication, String secure, String username, String password, String from)
host
- The SMTP server address.port
- The SMTP server port (e.g. 25, 587, 465).socketTimeout
- The socket connection timeout value in milliseconds.useAuthentication
- Determines whether authentication is needed for the SMTP server.secure
- The encryption security layer to use for the SMTP connection ("TLS" or "SSL"). If
left blank, no encryption layer will be used.username
- If authentication is required, the username to authenticate with.password
- If authentication is required, the password to authenticate with.from
- The FROM field to use for dispatched e-mail messages.public SMTPConnection(String host, String port, boolean useAuthentication, String secure, String username, String password, String from)
host
- The SMTP server address.port
- The SMTP server port (e.g. 25, 587, 465).useAuthentication
- Determines whether authentication is needed for the SMTP server.secure
- The encryption security layer to use for the SMTP connection ("TLS" or "SSL"). If
left blank, no encryption layer will be used.username
- If authentication is required, the username to authenticate with.password
- If authentication is required, the password to authenticate with.from
- The FROM field to use for the e-mail.public String getHost()
public void setHost(String host)
host
- The SMTP server address to use.public String getPort()
public void setPort(String port)
port
- The SMTP server port to use (e.g. 25, 587, 465).public boolean isUseAuthentication()
public void setUseAuthentication(boolean useAuthentication)
useAuthentication
- Determines whether authentication is needed for the SMTP server.public String getSecure()
public void setSecure(String secure)
secure
- The encryption security layer to use for the SMTP connection ("TLS" or "SSL"). If
left blank, no encryption layer will be used.public String getUsername()
public void setUsername(String username)
username
- The username to authenticate with.public String getPassword()
public void setPassword(String password)
password
- The password to authenticate with.public String getFrom()
public void setFrom(String from)
from
- The FROM field to use for dispatched e-mail messages.public int getSocketTimeout()
public void setSocketTimeout(int socketTimeout)
socketTimeout
- The socket connection timeout value in milliseconds.public void send(String toList, String ccList, String from, String subject, String body, String charset) throws org.apache.commons.mail.EmailException
toList
- A string representing a list of e-mail addresses to send the message to (separated
by ",").ccList
- A string representing a list of e-mail addresses to copy the message to (separated
by ",").from
- The FROM field to use for the e-mail message.subject
- The subject of the e-mail message.body
- The content of the e-mail message.charset
- The charset encoding to use when sending the e-mail message.org.apache.commons.mail.EmailException
- If an error occurred while sending the e-mail message.public void send(String toList, String ccList, String from, String subject, String body) throws org.apache.commons.mail.EmailException
toList
- A string representing a list of e-mail addresses to send the message to (separated
by ",").ccList
- A string representing a list of e-mail addresses to copy the message to (separated
by ",").from
- The FROM field to use for the e-mail message.subject
- The subject of the e-mail message.body
- The content of the e-mail message.org.apache.commons.mail.EmailException
- If an error occurred while sending the e-mail message.public void send(String toList, String ccList, String subject, String body) throws org.apache.commons.mail.EmailException
toList
- A string representing a list of e-mail addresses to send the message to (separated
by ",").ccList
- A string representing a list of e-mail addresses to copy the message to (separated
by ",").subject
- The subject of the e-mail message.body
- The content of the e-mail message.org.apache.commons.mail.EmailException
- If an error occurred while sending the e-mail message.