Vert.x 2.x is deprecated - use instead http://vertx.io/docs/vertx-mail-client/java/
Mailer
This module allows emails to be sent via SMTP.
Dependencies
This module requires a mail server to be available.
Name
The module name is mailer.
Configuration
The mailer module requires the following configuration:
{
"address": <address>,
"host": <host>,
"port": <port>,
"ssl": <ssl>,
"auth": <auth>,
"username": <username>,
"password": <password>,
"content_type": <content_type>
}
Let's take a look at each field in turn:
addressThe main address for the busmod. Every busmod has a main address.hostHost name or ip address of the mail server instance. Defaults tolocalhost.portPort at which the mail server is listening. Defaults to25.sslIftruethen use ssl, otherwise don't use ssl. Default isfalse.authIftrueuse authentication, otherwise don't use authentication. Default isfalse.usernameIf using authentication, the username. Default isnull.passwordIf using authentication, the password. Default isnull.content_typeIf you want to send HTML email body, then set totext/html. Default istext/plain.
For example, to send to a local server on port 25:
{
"address": "test.my_mailer"
}
Or to a gmail account:
{
"address": "test.my_mailer"
"host": "smtp.googlemail.com",
"port": 465,
"ssl": true,
"auth": true,
"username": "tim",
"password": "password"
}
Sending Emails
To send an email just send a JSON message to the main address of the mailer. The JSON message representing the email should have the following structure:
{
"from": <from>,
"to": <to|to_list>,
"cc": <cc|cc_list>
"bcc": <bcc|bcc_list>
"subject": <subject>
"body": <body>,
"headers": <headers_list>
}
Where:
fromis the sender address of the email. Must be a well-formed email address.toto is either a single well formed email address representing the recipient or a JSON array of email addresses representing the recipients. This field is mandatory.ccto is either a single well formed email address representing a cc recipient or a JSON array of email addresses representing the cc list. This field is optional.bccto is either a single well formed email address representing a bcc recipient or a JSON array of email addresses representing the bcc list. This field is optional.subjectis the subject of the email. This field is mandatory.bodyis the body of the email. This field is mandatory.headersis a JSON array of JSON object representing the name of an header and it's value. This field is optional.
For example, to send a mail to a single recipient:
{
"from": "tim@wibble.com",
"to": "bob@wobble.com",
"subject": "Congratulations on your new armadillo!",
"body": "Dear Bob, great to here you have purchased......"
}
Or to send to multiple recipients:
{
"from": "tim@wibble.com",
"to": ["bob@wobble.com", "jane@tribble.com"],
"subject": "Sadly, my aardvark George, has been arrested.",
"body": "All, I'm afraid George was found...."
}
Or to send to multiple recipients with additional headers:
{
"from": "tim@wibble.com",
"to": ["bob@wobble.com", "jane@tribble.com"],
"subject": "Sadly, my aardvark George, has been arrested.",
"body": "All, I'm afraid George was found....",
"headers": [{"name": "X-My-Header","value": "Header's value"}]
}