Sending Emails
Emails are sent using SendMailSession
. Mail session encapsulates the process of preparing emails, opening and closing transport connections, and sending emails.
Mail session is created by the MailServer
.
Since opening session and sending emails may produce EmailException
, it is necessary to wrap methods in try
-catch
block and closing the session in the finally
block.
Sending using SSL
The preferred way of sending e-mails is by using SSL protocol. Jodd supports secure e-mail sending. Just set the ssl()
flag while creating the server.
Here is an example of sending e-mail via Gmail (port 465
is set by default):
Everything is the same, just a different session provider is used.
Last updated