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.
By default these example starts a "fake" mails server (just logging on the console):
If you want to use a different SMTP server, just remove this line and configure the options.
The examples use a few different configs
Just send a mail without authentication.
Send a mail to an external smtp server (e.g. googlemail, sendgrid, aol etc) requiring a login.
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
To specifically select a AUTH method or define the order of preference, you
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
This example shows how to leave out the From address in a mail but setting the bounceAddress property instead.
the example deploys the mail service, however you can refactor the example to skip this step and start the service as follows:
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 example shows how you can send headers in a mail.
This example shows how to send inlined images in mails.