public class MailSession extends Properties
The SMTP protocol provider supports the following properties, which may be set in the MailSession
object. The properties are always set as strings; the Type column describes how the string is interpreted. For
example, use
props.put("mail.smtp.port", "888");to set the
mail.smtp.port
property, which is of type int.
Name | Type | Description |
---|---|---|
mail.smtp.user | String | Default user name for SMTP. |
mail.smtp.password | String | SMTP Password for the default user name. |
mail.smtp.host | String | The SMTP server to connect to. |
mail.smtp.port | int | The SMTP server port to connect to, if the connect() method doesn't explicitly specify one. Defaults to 25. |
mail.smtp.connectiontimeout | int | Socket connection timeout value in milliseconds. Default is 5000 milliseconds. |
mail.smtp.timeout | int | Socket I/O timeout value in milliseconds. Default is 2000 milliseconds. |
mail.smtp.from | String | Email address to use for SMTP MAIL command. This sets the envelope return address. Defaults to msg.getFrom()[0] or ConnectionManager.getLocalHost(). NOTE: mail.smtp.user was previously used for this. |
mail.smtp.auth | boolean | If true, attempt to authenticate the user using the AUTH command. Defaults to false. |
mail.smtp.starttls.enable | boolean |
If true, enables the use of the STARTTLS command (if supported by the server) to switch the connection
to a TLS-protected connection before issuing any login commands. Note that an appropriate trust store must configured
so that the client will trust the server's certificate. Defaults to false. |
mail.smtp.starttls.required | boolean | If true, requires the use of the STARTTLS command. If the server doesn't support the STARTTLS command, or the command fails, the connect method will fail. Defaults to false. |
mail.smtp.ssl.port | int | The SMTP server port to connect to when STARTTLS is enabled, if the connect() method doesn't explicitly specify one. Defaults to 587. |
mail.smtp.ssl.socketFactory.class | String | If set, specifies the name of a class that extends the totalcross.net.ssl.SSLSocketFactory class. This class will be used to create SMTP SSL sockets. |
The POP3 protocol provider supports the following properties, which may be set in the MailSession
object. The properties are always set as strings; the Type column describes how the string is interpreted. For
example, use
props.put("mail.pop3.port", "888");to set the
mail.pop3.port
property, which is of type int.
Name | Type | Description |
---|---|---|
mail.pop3.user | String | Default user name for POP3. |
mail.pop3.host | String | The POP3 server to connect to. |
mail.pop3.port | int | The POP3 server port to connect to, if the connect() method doesn't explicitly specify one. Defaults to 110. |
mail.pop3.connectiontimeout | int | Socket connection timeout value in milliseconds. Default is infinite timeout. |
mail.pop3.timeout | int | Socket I/O timeout value in milliseconds. Default is infinite timeout. |
Properties.Boolean, Properties.Double, Properties.Int, Properties.Long, Properties.Str, Properties.Value
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
POP3_CONNECTIONTIMEOUT |
static java.lang.String |
POP3_HOST |
static java.lang.String |
POP3_PASS |
static java.lang.String |
POP3_PORT |
static java.lang.String |
POP3_TIMEOUT |
static java.lang.String |
POP3_USER |
static java.lang.String |
SMTP_AUTH
If true, attempt to authenticate the user using the AUTH command.
|
static java.lang.String |
SMTP_CONNECTIONTIMEOUT
Socket connection timeout value in milliseconds.
|
static java.lang.String |
SMTP_FROM
Email address to use for SMTP MAIL command.
|
static java.lang.String |
SMTP_HOST
The SMTP server to connect to.
|
static java.lang.String |
SMTP_PASS
SMTP Password for the default user name.
|
static java.lang.String |
SMTP_PORT
The SMTP server port to connect to, if the connect() method doesn't explicitly specify one.
|
static java.lang.String |
SMTP_SSL_PORT
The SMTP server port to connect to when STARTTLS is enabled, if the connect() method doesn't explicitly specify
one.
|
static java.lang.String |
SMTP_SSL_SOCKET_FACTORY_CLASS
If set, specifies the name of a class that extends the totalcross.net.ssl.SSLSocketFactory class.
|
static java.lang.String |
SMTP_STARTTLS
If true, enables the use of the STARTTLS command (if supported by the server) to switch the connection to a
TLS-protected connection before issuing any login commands.
|
static java.lang.String |
SMTP_STARTTLS_REQUIRED
If true, requires the use of the STARTTLS command.
|
static java.lang.String |
SMTP_TIMEOUT
Socket I/O timeout value in milliseconds.
|
static java.lang.String |
SMTP_USER
Default user name for SMTP.
|
MAX_PROPS
Modifier | Constructor and Description |
---|---|
protected |
MailSession() |
Modifier and Type | Method and Description |
---|---|
static MailSession |
getDefaultInstance()
Returns a static instance of MailSession, which may be initialized during the application startup.
|
static MailSession |
getInstance()
Creates a new empty MailSession.
|
Store |
getStore(java.lang.String protocol)
Get a Store object that implements the specified protocol.
|
Transport |
getTransport(java.lang.String protocol)
Get a Transport object that implements the specified protocol.
|
void |
load(DataStream ds)
Load properties from the given DataStream, but unlike Properties, the contents of the MailSession are not cleared
before reading from the DataStream.
|
clear, dumpKeysValues, get, getKeys, load, put, remove, save, size
public static final java.lang.String SMTP_USER
public static final java.lang.String SMTP_PASS
public static final java.lang.String SMTP_HOST
public static final java.lang.String SMTP_PORT
public static final java.lang.String SMTP_CONNECTIONTIMEOUT
public static final java.lang.String SMTP_TIMEOUT
public static final java.lang.String SMTP_FROM
public static final java.lang.String SMTP_AUTH
public static final java.lang.String SMTP_STARTTLS
public static final java.lang.String SMTP_STARTTLS_REQUIRED
public static final java.lang.String SMTP_SSL_PORT
public static final java.lang.String SMTP_SSL_SOCKET_FACTORY_CLASS
public static final java.lang.String POP3_USER
public static final java.lang.String POP3_HOST
public static final java.lang.String POP3_PORT
public static final java.lang.String POP3_CONNECTIONTIMEOUT
public static final java.lang.String POP3_TIMEOUT
public static final java.lang.String POP3_PASS
public static MailSession getInstance()
public static MailSession getDefaultInstance()
public Store getStore(java.lang.String protocol)
protocol
- public Transport getTransport(java.lang.String protocol)
protocol
- public void load(DataStream ds) throws IOException
load
in class Properties
IOException