Session
classin packageklyn.mails
public class Session extends Object:
└ Session
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"
Fields
Modifier and Type Member Description
public Session(host
Session(host as String = "",
Creates a mail session.
Properties
Modifier and Type Member Description
public property authenticator
authenticator as Authenticator
Optional lazy authenticator.
public readonly property clientName
clientName as String:
Returns the EHLO/HELO client name.
public property defaultFrom
defaultFrom as InternetAddress
Optional default sender address.
public readonly property effectivePort
effectivePort as Int:
Returns the effective SMTP port for this session.
public property heloName
heloName as String
Optional EHLO/HELO client name.
public property host
host as String
SMTP host name.
public property password
password as String
SMTP login password.
public property port
port as Int
SMTP port.
public property security
security as MailSecurity
Plain SMTP, direct TLS or STARTTLS.
public property sslContext
sslContext as SSLContext
Optional TLS context for direct SMTPS connections.
public property userName
userName as String
SMTP login user name.
Properties inherited from Object: type
Methods
Modifier and Type Member Description
public deliver
deliver(message as MimeMessage) as SmtpResponse throws MessagingException:
Sends a message through this session.
public openTransport
openTransport() as SmtpTransport:
Opens an SMTP transport bound to this session.
public static smtp
smtp(host as String, port as Int = 0, security as MailSecurity = MailSecurity.NONE) as Session:
Creates an SMTP session.
Methods inherited from Object: fromJson, toDict, toJson, toString, toXml