README.md

Nodemailer

Nodemailer is an easy to use module to send e-mails with Node.JS (using
SMTP or sendmail or Amazon SES) and is unicode friendly - You can use any characters you like ✔

Nodemailer is Windows friendly, you can install it with npm on Windows just like any other module, there are no compiled dependencies. Use it from Azure or from your Windows box hassle free.

Version v0.3 of Nodemailer is built from scratch and might break some existing scripts, so beware while upgrading. Nodemailer should be backwards compatible - if your script worked before, then it should work now, even if Nodemailer documentation differs from your code (method names, properties etc.).

callback is the callback function that will be run after the e-mail is sent or the sending failed (see Return callback for details)

Setting up a transport method

Before you can send any e-mails you need to set up a transport method. This can
be done with nodemailer.createTransport(type, options) where type indicates
the transport protocol and options defines how it is used.

var transport = nodemailer.createTransport("SMTP", {smtp_options});

The same transport object can and should be reused several times.

When the transport method is defined, it should be attached to the message
object as transport

Possible transport methods

Required type parameter can be one of the following:

SMTP for using SMTP

SES for using Amazon SES

Sendmail for utilizing systems sendmail command

Setting up SMTP

SMTP is different from the other transport mechanisms, as in its case a connection
pool is created. All the connections try to stay alive as long as possible and
are reusable to minimize the protocol overhead delay - for example setting up
TLS for authenticating is relatively lengthy process (in CPU terms, not by human
terms), you do not want to do it several times.

Possible SMTP options are the following:

service - an optional well known service identifier ("Gmail", "Hotmail" etc., see Well known Services for a list of supported services) to auto-configure host, port and secure connection settings

host - hostname of the SMTP server (defaults to "localhost", not needed with service)

port - port of the SMTP server (defaults to 25, not needed with service)

secureConnection - use SSL (default is false, not needed with service). If you're using port 587 then keep secureConnection false, since the connection is started in insecure plain text mode and only later upgraded with STARTTLS

name - the name of the client server (defaults to machine name)

auth - authentication object as {user:"...", pass:"..."}

ignoreTLS - ignore server support for STARTTLS (defaults to false)

debug - output client and server messages to console

maxConnections - how many connections to keep in the pool (defaults to 5)

You can even use unicode domain and user names, these are automatically converted
to the supported form

"Uncode Domain" <info@müriaad-polüteism.info>

Using Embedded Images

Attachments can be used as embedded images in the HTML body. To use this
feature, you need to set additional property of the attachment - cid (unique
identifier of the file) which is a reference to the attachment file. The same
cid value must be used as the image URL in HTML (using cid: as the URL
protocol, see example below).

Tests

There aren't currently many tests for Nodemailer but there are a lot of tests
in the modules that are used to generate the raw e-mail body and to use the
SMTP client connection.

Tweaking

Nodemailer in itself is actually more like a wrapper for my other modules
mailcomposer for composing the raw message stream
and simplesmtp for delivering it, by providing an
unified API. If there's some problems with particular parts of the
message composing/sending process you should look at the appropriate module.

License

Nodemailer is licensed under MIT license. Basically you can do whatever you want to with it.