SMTPClient
The SMTPClient utility implements an SMTP client and can be used to send e-mail messages. It is configured with an optional username and password and a set of properties. The provided username and password will be used if the SMTP Server requires user authentication. The set of properties is used to set up an SMTP session which the SMTPClient holds.
The set of properties is expected to contain JavaMail API properties as documented in https://javaee.github.io/javamail/docs/api/overview-summary.html#Properties. In particular, this includes the properties documented in https://javaee.github.io/javamail/docs/api/com/sun/mail/smtp/package-summary.html. If not set explicitly, default values are set for the properties mail.smtp[s].connectiontimeout (10000), mail.smtp[s].timeout (30000), mail.smtp[s].writetimeout (30000) and mail.smtps.ssl.protocols (TLSv1.2 TLSv1.3).
If used by an AuthState, the SMTPClient can be configured via the properties of the AuthState.
Properties
mail.*(String)JavaMail properties as defined in the JavaMail API documentaiton and in particular the SMTP package
Nevis specific properties
The following properties are used in the creation of an SSLSocketFactory which is than configured using the mail.smtps.ssl.socketFactory property.
Thefore it is assumed that the protocol is configured to be mail.transport.protocol=smtps.
mail.smtps.tls.keyObjectRef(String, optional, -)This property configures the key material containing the client certificates to use when TLS ClientAuth (or 2 way TLS) is required. The referenced keystore must be defined inside a
KeyStoreelement of the nevisAuth esauth4.xml configuration.Format<keystore-reference>/<keyobject-reference>ExampleDefaultKeyStore/DefaultSignerVariable substitution is only allowed for the whole property value, for example:
${keystore-and-keyobj-ref}mail.smtps.tls.trustStoreRef(String, optional, JVM default)The keystore reference that is being used as truststore. The referenced keystore must be defined inside a
KeyStoreelement of the nevisAuth esauth4.xml configuration.If this value is not supplied, the default JVM truststore is used.
SMTPS vs SMTP
STPMS is usually mentioned as the TLS secured SMTP protocol. Though SMTPS does not exists as a separate protocol in specifications or in practice.
In Java, the STMPS is nothing more than a shortened form to define SMTP with TLS enabled.
Defining
mail.transport.protocol=smtp
mail.smtp.ssl.enable=true
is the same as
mail.transport.protocol=smtps
This also means, that all properties defined by javadoc in the links above are available for both mail.smtp.* and mail.smtps.*.
However, you should make sure to define them consistently. So either use smtps or smtp everywhere, because smtps properties do not fall back to smtp properties!
It is recommended to use the mail.transport.protocol=smtps to avoid any confusion on property names and if TLS is enabled or not.
Then to match this configure properties mail.smtps..
Example
SMTPClient using SMTP as the transport protocol can be obtained with the following properties:
mail.smtp.host = "mail.yourprovider.ch"
mail.smtp.port = "25"
mail.transport.protocol = "smtp"
SMTPClient using SMTPS as the transport protocol can be obtained with the following properties:
mail.smtps.host = "mail.yourprovider.ch"
mail.smtps.port = "465"
mail.transport.protocol = "smtps"