TLS
TLS (Transport Layer Security) encrypts the connection to your SMTP server. Kotlinmailer verifies the server's certificate using the platform's trust store.
Security modes
SmtpSecurity.STARTTLS fails if the server does not offer STARTTLS. STARTTLS_IF_AVAILABLE and NONE may send emails unencrypted and should only be used in trusted networks, e.g. for a relay on localhost. Credentials are never sent over an unencrypted connection unless you set allowInsecureAuth = true.
Platforms
Platform | TLS implementation |
|---|---|
JVM / Android | Ktor ( |
macOS, iOS | Foundation streams (system TLS) |
Node.js | Node's |
Linux, Windows native | not available, only |
Custom certificates
On the JVM you can configure the TLS handshake, e.g. to trust the self-signed certificate of a test server:
On Node.js, pass options to tls.connect, e.g. NodeSmtpSocketFactory(js("({ ca: myCa })")).
To run SMTP over a completely custom transport, implement SmtpSocket and SmtpSocketFactory.