Migration from 0.x to 1.x

E-mail message fields

  • Address fields allow mixing arrays with comma separated strings. You can also use {name: 'name', address: 'address'} objects instead of just strings for addresses. For example, this is a valid To: value:
[
    '[email protected], [email protected]',
    'Name <[email protected]>',
    {name: 'name', address: '[email protected]'}
]
  • generateTextFromHTML is removed (use nodemailer-html-to-text plugin instead)
  • charset is removed
  • dsn is removed
  • html and text take unicode strings, Buffer objects, Stream objects and attachment objects ({path: 'message.html'}) as the values.
  • headers does not support Objects as values (an object is not automatically JSONized anymore)

Attachment fields

  • fileName is now filename
  • filePath is now path
  • contents is now content
  • streamSource is dropped, use content instead
  • content accepts unicode strings, Buffer objects and Stream objects
  • Streams do not need to be explicitly paused, this is handled by the Streams2 flow mechanism

Alternatives

Uses the same structure as attachments so you can use Streams or files for the content.

DKIM

DKIM signing is not built in and there is no useDKIM() method anymore. Instead you can use the nodemailer-dkim plugin to add signing support. DKIM is still not efficient, as it requires the entire message to be buffered before it can be signed, so beware large attachments when using DKIM.

Transports

Instead of specifying the transport name as a string (eg. ‘SMTP’), use transport object constructors.

This is the old way (does not work in 1.0) of creating a transporter object:

var transporter = nodemailer.createTransport('SMTP', opts);  

Now use this:

var tranport = require('transport-plugin-name');  
var transporter = nodemailer.createTransport(transport(opts));  

or for the bundled SMTP transport use:

var transporter = nodemailer.createTransport(opts);  

SMTP

SMTP support is divided into three plugins

  • nodemailer-direct-transport sends messages one by one (new connection for every message) directly to the recipients MX. Used automatically if no configuration is provided to createTransport()
var transporter = nodemailer.createTransport(); // <- zero conf  
  • nodemailer-smtp-transport sends messages one by one (new connection for every message) to a specified SMTP gateway. Bundled with Nodemailer so you do not have to install it separately to use it
  • nodemailer-smtp-pool creates a pool of connections against the specified SMTP gateway and sends messages using available connections in the pool. This used to be the default handler for the ‘SMTP’ transport in Nodemailer 0.x but in 1.0 it is an optional add on and the bundled SMTP transport does not use pooling anymore. If you send only occasional emails, then the pooling gives no advantage and might cause some issues with long idling connections. If you send a lot of emails, then you should definitely consider using pooling.

SES

You can find SES support from nodemailer-ses-transport

sendmail

You can find Sendmail support from nodemailer-sendmail-transport

pickup

You can find Pickup support from nodemailer-pickup-transport