public class Session extends Object:
SMTP session configuration inspired by JavaMail Session, adapted to Klyn.
Instead of a generic property bag, the main SMTP concerns are exposed as typed properties: host, port, security mode, credentials and TLS context.
import klyn.mails
session = Session.smtp("smtp.example.com", security=MailSecurity.SSL_TLS)
session.userName = "robot@example.com"
session.password = "secret"| Modifier and Type | Member | Description |
|---|---|---|
| public property | authenticatorauthenticator as Authenticator |
Optional lazy authenticator. |
| public readonly property | clientNameclientName as String: |
Returns the EHLO/HELO client name. |
| public property | defaultFromdefaultFrom as InternetAddress |
Optional default sender address. |
| public readonly property | effectivePorteffectivePort as Int: |
Returns the effective SMTP port for this session. |
| public property | heloNameheloName as String |
Optional EHLO/HELO client name. |
| public property | hosthost as String |
SMTP host name. |
| public property | passwordpassword as String |
SMTP login password. |
| public property | portport as Int |
SMTP port. |
| public property | securitysecurity as MailSecurity |
Plain SMTP, direct TLS or STARTTLS. |
| public property | sslContextsslContext as SSLContext |
Optional TLS context for direct SMTPS connections. |
| public property | userNameuserName as String |
SMTP login user name. |
| Modifier and Type | Member | Description |
|---|---|---|
| public | SessionSession(host as String = "",
port as Int = 0,
security as MailSecurity = MailSecurity.NONE,
userName as String = "",
password as String = "",
sslContext as SSLContext = null): |
Creates a mail session. |
| Modifier and Type | Member | Description |
|---|---|---|
| public | deliverdeliver(message as MimeMessage) as SmtpResponse throws MessagingException: |
Sends a message through this session. |
| public | openTransportopenTransport() as SmtpTransport: |
Opens an SMTP transport bound to this session. |
| public static | smtpsmtp(host as String, port as Int = 0, security as MailSecurity = MailSecurity.NONE) as Session: |
Creates an SMTP session. |