Skip to content

Latest commit

 

History

History
 
 

mail-examples

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

Vert.x Mail examples

Here you’ll find some examples how to use Vert.x mail-service to send mails to a SMTP server either from the local machine or via the event bus on another machine.

The examples use a few different configs

Send a mail to localhost:25, e.g. to postfix running on the local machine

Send a mail to an external smtp server (e.g. googlemail, sendgrid, aol etc) requiring a login and enforcing use of TLS. The operation will fail if either the account is not set or the server doesn’t announce STARTTLS capability.

The login will currently use DIGEST-MD5, CRAM-MD5, PLAIN and LOGIN in order of preference, if the server announces AUTH but you don’t need it (e.g. if you are authenticated by a local ip address) turn login off with LoginOption.DISABLE To specifically select a AUTH method or define the order of preference, you can do setAuthMethods("METHOD1 METHOD2").

Send a mail via the event bus to another vert.x instance registered as vertx.mail. This will use the config set by the service and doesn’t use a local config object.

This example shows how to leave out the From address in a mail but setting the bounceAddress property instead.

The service listening on the event bus can be started with

vertx run service:io.vertx.mail-service

and vertx will pick up the package from maven and start it with default config.

Send a mail with supplied headers (e.g. Received, Message-ID, Reply-To)

This test uses a SSL connect to the mail server using Port 465 (which is actually deprecated, but is supported by many mail servers e.g. googlemail and AOL support port 465). The preferred way to send secure mails is TLS required and port 587.