Skip to content
Fetching contributors…
Cannot retrieve contributors at this time
59 lines (38 sloc) 1.28 KB

Address Object

The Address object is an interface to reading email addresses passed in at SMTP time. As such it parses all the formats in RFC-2821 and 2822, and supports correctly escaping email addresses.


  • new Address (user, host)

Create a new address object for user@host

  • new Address (email)

Creates a new address object by parsing the email address. Will throw an exception if the address cannot be parsed.

  • address.user

Access the local part of the email address


Access the domain part of the email adress

  • address.format()

Provides the email address in the appropriate <user@host> format. And deals correctly with the null sender and local names.

  • address.toString()

Same as format().

  • address.address()

Provides the email address in 'user@host' format.

Advanced Usage

It is possible to mess with the regular expressions used to match addresses for stricter or less strict matching.

To change the behaviour mess with the following variables:

var adr = require('./address');
// Now change one of the following. Note they are RegExp objects NOT strings.
// Don't forget to recompile:
Something went wrong with that request. Please try again.