{
  "name": "nodemailer",
  "description": "Easy to use module to send e-mails, supports unicode and SSL/TLS",
  "version": "0.6.0",
  "author": {
    "name": "Andris Reinman"
  },
  "maintainers": [
    {
      "name": "andris",
      "email": "andris@kreata.ee"
    }
  ],
  "homepage": "http://github.com/andris9/nodemailer",
  "repository": {
    "type": "git",
    "url": "http://github.com/andris9/nodemailer.git"
  },
  "scripts": {
    "test": "nodeunit test/"
  },
  "main": "./lib/nodemailer",
  "licenses": [
    {
      "type": "MIT",
      "url": "http://github.com/andris9/nodemailer/blob/master/LICENSE"
    }
  ],
  "dependencies": {
    "mailcomposer": "~0.2.7",
    "simplesmtp": "~0.2 || ~0.3",
    "directmail": "~0.1.6",
    "he": "~0.3.6",
    "public-address": "~0.1.0",
    "readable-stream": "~1.1.9"
  },
  "devDependencies": {
    "nodeunit": "*"
  },
  "optionalDependencies": {
    "readable-stream": "~1.1.9"
  },
  "engines": {
    "node": ">=0.6.0"
  },
  "keywords": [
    "e-mail",
    "mime",
    "email",
    "mail",
    "sendmail",
    "ses",
    "smtp"
  ],
  "readme": "Nodemailer\n==========\n\n**Nodemailer** is an easy to use module to send e-mails with Node.JS (using\nSMTP or sendmail or Amazon SES) and is unicode friendly - You can use any characters you like ✔\n\nNodemailer 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.\n\n**[Read about using Nodemailer from the Node Knockout blog](http://blog.nodeknockout.com/post/34641712180/sending-email-from-node-js)**\n\n[![Build Status](https://secure.travis-ci.org/andris9/Nodemailer.png)](http://travis-ci.org/andris9/Nodemailer)\n[![NPM version](https://badge.fury.io/js/nodemailer.png)](http://badge.fury.io/js/nodemailer)\n\n## Notes and information\n\n### Nodemailer supports\n\n  * **Unicode** to use any characters\n  * **HTML content** as well as **plain text** alternative\n  * **Attachments** (including attachment **streaming** for sending larger files)\n  * **Embedded images** in HTML\n  * **SSL/STARTTLS** for secure e-mail delivery\n  * Different transport methods - **SMTP**, **sendmail**, **Amazon SES** or **directly** to recipients MX server or even a **custom** method\n  * SMTP **Connection pool** and connection reuse for rapid delivery\n  * **Preconfigured** services for using SMTP with Gmail, Hotmail etc.\n  * Use objects as header values for **SendGrid** SMTP API\n  * **XOAUTH2** authentication and token generation support - useful with Gmail\n  * **DKIM** signing\n\n### Support Nodemailer development\n\n[![Donate to author](https://www.paypalobjects.com/en_US/i/btn/btn_donate_SM.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=DB26KWR2BQX5W)\n\nIf you want to support with Bitcoins, then my wallet address is `15Z8ADxhssKUiwP3jbbqJwA21744KMCfTM`\n\n### Nodemailer PaaS support\n\nNodemailer has been tested successfully on the following PaaS platforms (using free/trial accounts):\n\n  * [heroku](http://www.heroku.com/)\n  * [AppFog](http://www.appfog.com/)\n  * [OpenShift](https://openshift.redhat.com/app/)\n  * [Nodejitsu](http://nodejitsu.com/)\n  * [Windows Azure](http://www.windowsazure.com/)\n  * [Modulus](https://modulus.io/)\n\n### Check out my other mail related modules\n\nIf you want to parse generated or received e-mail instead of sending it, check\nout [MailParser](https://github.com/andris9/mailparser).\n\nIf you only want to generate the raw e-mail stream, check out\n[MailComposer](https://github.com/andris9/mailcomposer).\n\nIf you only want to communicate with the SMTP (both as client and the server),\ncheck out [simplesmtp](https://github.com/andris9/simplesmtp).\n\n### Templates\n\nTo use Nodemailer with templates, please see documentation for these projects.\n\n * [swig-email-templates](https://github.com/superjoe30/swig-email-templates) - swig, template inheritance, dummy context\n * [node-email-templates](https://github.com/niftylettuce/node-email-templates) - ejs\n\n## TL;DR Usage Example\n\nThis is a complete example to send an e-mail with plaintext and HTML body\n\n```javascript\nvar nodemailer = require(\"nodemailer\");\n\n// create reusable transport method (opens pool of SMTP connections)\nvar smtpTransport = nodemailer.createTransport(\"SMTP\",{\n    service: \"Gmail\",\n    auth: {\n        user: \"gmail.user@gmail.com\",\n        pass: \"userpass\"\n    }\n});\n\n// setup e-mail data with unicode symbols\nvar mailOptions = {\n    from: \"Fred Foo ✔ <foo@blurdybloop.com>\", // sender address\n    to: \"bar@blurdybloop.com, baz@blurdybloop.com\", // list of receivers\n    subject: \"Hello ✔\", // Subject line\n    text: \"Hello world ✔\", // plaintext body\n    html: \"<b>Hello world ✔</b>\" // html body\n}\n\n// send mail with defined transport object\nsmtpTransport.sendMail(mailOptions, function(error, response){\n    if(error){\n        console.log(error);\n    }else{\n        console.log(\"Message sent: \" + response.message);\n    }\n\n    // if you don't want to use this transport object anymore, uncomment following line\n    //smtpTransport.close(); // shut down the connection pool, no more messages\n});\n```\n\nOr if you want to go the really easy (but not the best) route, you can try to send e-mails directly to\nthe recipients MX server without a relaying service:\n\n```javascript\nvar mail = require(\"nodemailer\").mail;\n\nmail({\n    from: \"Fred Foo ✔ <foo@blurdybloop.com>\", // sender address\n    to: \"bar@blurdybloop.com, baz@blurdybloop.com\", // list of receivers\n    subject: \"Hello ✔\", // Subject line\n    text: \"Hello world ✔\", // plaintext body\n    html: \"<b>Hello world ✔</b>\" // html body\n});\n```\n\nSee also the [examples folder](https://github.com/andris9/Nodemailer/tree/master/examples)\nfor full featured examples\n\n## Installation\n\nInstall through NPM\n\n```\nnpm install nodemailer\n```\n\n## Usage\n\nInclude the module\n\n```javascript\nvar nodemailer = require(\"nodemailer\");\n```\n\nAn e-mail can be sent with `sendMail(mailOptions[, callback])` command\n\n```javascript\ntransport.sendMail(mailOptions, callback);\n```\n\nWhere\n\n  * `transport` is a transport object created from the `nodemailer.createTransport` method\n  * **mailOptions** defines the e-mail (set its subject, body text, receivers etc.), see [E-mail Message Fields](#e-mail-message-fields) for details\n  * **callback** is the callback function that will be run after the e-mail is sent or the sending failed (see [Return callback](#return-callback) for details)\n\n## Setting up a transport method\n\nBefore you can send any e-mails you need to set up a transport method. This can\nbe done with `nodemailer.createTransport(type, options)` where `type` indicates\nthe transport protocol and `options` defines how it is used.\n\n```javascript\nvar transport = nodemailer.createTransport(\"SMTP\", {smtp_options});\n```\n\nThe same transport object can and should be reused several times.\n\nWhen the transport method is defined, it can be used to send e-mail with `sendMail`\n\n```javascript\nvar transport = nodemailer.createTransport(\"SMTP\", {smtp_options});\n\ntransport.sendMail({\n    from: \"sender@tr.ee\",\n    to: \"receiver@tr.ee\"\n    ...\n});\n```\n\n### Possible transport methods\n\n`type` parameter can be one of the following:\n\n  * **SMTP** for using SMTP\n  * **SES** for using Amazon SES\n  * **Sendmail** for utilizing systems *sendmail* command\n  * **Pickup** for storing the e-mail in a directory on your machine\n  * **Direct** for sending e-mails directly to recipients MTA servers\n\nIf `type` is not set, \"direct\" will be used\n\nIf you want to use custom transport method, you need to provide the transport handler constructor as the `type` parameter. See [Custom Transport Methods](#custom-transport-methods) for details\n\n### Global transport options\n\nIn addition to any specific configuration for a selected transport type, a few global\nones exist.\n\n  * **resolveHostname** - if set to true, resolves the public hostname for the current machine (makes an external HTTP request to [remoteAddress.net](http://www.remoteaddress.net/) for resolving it). The value is used when generating `Message-ID` values (as the domain part) and when identifying itself to a SMTP server\n  * **xMailer** - if the value is a string it replaces the default `X-Mailer` header value. If the value is `false` then `X-Mailer` is stripped from the header\n\n### Setting up SMTP\n\nSMTP is different from the other transport mechanisms, as in its case a connection\npool is created. All the connections try to stay alive as long as possible and\nare reusable to minimize the protocol overhead delay - for example setting up\nTLS for authenticating is relatively lengthy process (in CPU terms, not by human\nterms), you do not want to do it several times.\n\nPossible SMTP options are the following:\n\n * **service** - an optional well known service identifier (\"Gmail\", \"Hotmail\" etc., see [Well known Services](#well-known-services-for-smtp) for a list of supported services) to auto-configure host, port and secure connection settings\n * **host** - hostname of the SMTP server (defaults to \"localhost\", not needed with `service`)\n * **port** - port of the SMTP server (defaults to 25, not needed with `service`)\n * **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\n * **name** - the name of the client server (defaults to machine name)\n * **auth** - authentication object as `{user:\"...\", pass:\"...\"}` or  `{XOAuth2: {xoauth2_options}}` or  `{XOAuthToken: \"base64data\"}`\n * **ignoreTLS** - ignore server support for STARTTLS (defaults to `false`)\n * **debug** - output client and server messages to console\n * **maxConnections** - how many connections to keep in the pool (defaults to 5)\n * **maxMessages** - limit the count of messages to send through a single connection (no limit by default)\n\nExample:\n\n```javascript\nvar transport = nodemailer.createTransport(\"SMTP\", {\n    service: \"Gmail\",\n    auth: {\n        user: \"gmail.user@gmail.com\",\n        pass: \"userpass\"\n    }\n});\n```\n\nor the same without `service` parameter\n\n```javascript\nvar transport = nodemailer.createTransport(\"SMTP\", {\n    host: \"smtp.gmail.com\", // hostname\n    secureConnection: true, // use SSL\n    port: 465, // port for secure SMTP\n    auth: {\n        user: \"gmail.user@gmail.com\",\n        pass: \"userpass\"\n    }\n});\n```\n\n**NB!** if you want to close the pool (cancel all open connections) you can use `transport.close()`\n\n```javascript\n\nvar transport = nodemailer.createTransport(\"SMTP\",{});\n...\ntransport.close(); // close the pool\n```\n\n\n#### SMTP XOAUTH and token generation\n\n##### XOAUTH2\n\n**nodemailer** supports XOAUTH2 authentication protocol. To use this you need to obtain a Client ID and a Client Secret from [Google API Console](https://code.google.com/apis/console) (Open \"API Access\" and create \"Client ID for web applications\") and then request a refresh token for an user. See [Google OAuth 2.0 Offline Access](https://developers.google.com/accounts/docs/OAuth2WebServer#offline) for more information.\n\nOnce you have obtained the Client ID, Client Secret and a Refresh Token for an user, you can use these values to send mail on behalf of the user.\n\n```javascript\nvar transportOptions = {\n    ...,\n    auth: {\n        XOAuth2: {\n            user: \"example.user@gmail.com\",\n            clientId: \"8819981768.apps.googleusercontent.com\",\n            clientSecret: \"{client_secret}\",\n            refreshToken: \"1/xEoDL4iW3cxlI7yDbSRFYNG01kVKM2C-259HOF2aQbI\",\n            accessToken: \"vF9dft4qmTc2Nvb3RlckBhdHRhdmlzdGEuY29tCg==\",\n            timeout: 3600\n        }\n    }\n}\n```\n\n`accessToken` and `timeout` values are both optional. If XOAUTH2 login fails a new access token is generated automatically and the login is retried.\n\n##### XOAUTH\n\nOlder XOAUTH is also supported by **nodemailer** for SMTP. XOAUTH is based on OAuth protocol 1.0 and is considered deprecated.\n\nTo use this, include `XOAuthToken` option in `auth` instead of the regular `user` and `pass`.\n\n```javascript\nvar transportOptions = {\n    ...,\n    auth: {\n        XOAuthToken: \"R0VUIGh0dHBzOi8vbWFpbC5nb29....\"\n    }\n}\n```\n\n**nodemailer** includes also built in XOAUTH token generator which can be used\nwith `nodemailer.createXOAuthGenerator()`. The function is preconfigured for\nGmail, so in this case only mandatory options are `user`, `token` and `tokenSecret`.\n\n```javascript\nvar XOAuthTokenGenerator = nodemailer.createXOAuthGenerator({\n        user: \"test.nodemailer@gmail.com\",\n        // requestUrl: \"https://oauth.access.point\",\n        // consumerKey: \"anonymous\",\n        // consumerSecret: \"anonymous\",\n        token: \"1/O_HgoO4h2uOUfpus0V--7mygICXrQQ0ZajB3ZH52KqM\",\n        tokenSecret: \"_mUBkIwNPnfQBUIWrJrpXJ0c\"\n    });\n```\n\nOne of `user` or `requestUrl` is mandatory. `consumerKey` and `consumerSecret` both\ndefault to `\"anonymous\"`.\n\n```javascript\nvar transportOptions = {\n    service: \"Gmail\",\n    auth: {\n        XOAuthToken: nodemailer.createXOAuthGenerator({\n            user: \"test.nodemailer@gmail.com\",\n            token: \"1/O_HgoO4h2uOUfpus0V--7mygICXrQQ0ZajB3ZH52KqM\",\n            tokenSecret: \"_mUBkIwNPnfQBUIWrJrpXJ0c\"\n        })\n    }\n}\n```\n\n### Setting up SES\n\nSES is actually a HTTP based protocol, the compiled e-mail and related info\n(signatures and such) are sent as a HTTP request to SES servers.\n\nPossible SES options are the following:\n\n * **AWSAccessKeyID** - AWS access key (required)\n * **AWSSecretKey** - AWS secret (required)\n * **ServiceUrl** - optional API end point URL (defaults to *\"https://email.us-east-1.amazonaws.com\"*)\n\nExample:\n\n```javascript\nvar transport = nodemailer.createTransport(\"SES\", {\n    AWSAccessKeyID: \"AWSACCESSKEY\",\n    AWSSecretKey: \"AWS/Secret/key\"\n});\n```\n\n### Setting up Sendmail\n\nSendmail transport method streams the compiled message to the *stdin* of *sendmail*\ncommand.\n\nOptions object is optional, possible sendmail options are the following:\n\n  * **path** - path to the `sendmail` command (defaults to *\"sendmail\"*)\n  * **args** - an array of extra command line options to pass to the `sendmail` command (ie. `[\"-f\", \"foo@blurdybloop.com\"]`).\n\nCurrently the command to be spawned is built up like this: the command is either using `sendmail -i -f from_addr to_addr[]` (by default) or `sendmail -i list_of_args[]` (if `args` property was given). `-i` is ensured to be present on either case.\n\nIn the default case (no `args` defined) From and To addresses are either taken from `From`,`To`, `Cc` and `Bcc` properties or from the `envelope` property if one is present.\n\nBe wary when using the `args` property - no recipients are defined by default, you need to ensure these by yourself, for example by using the `-t` flag.\n\nExample:\n\n```javascript\nvar transport = nodemailer.createTransport(\"sendmail\");\n```\n\nor\n\n```javascript\nvar transport = nodemailer.createTransport(\"sendmail\", {\n    path: \"/usr/local/bin/sendmail\",\n    args: [\"-t\", \"-f\", \"foo@blurdybloop.com\"]\n});\n```\n\nSendmail uses a Transform stream, which is available in NodeJS >= 0.10. For\nprevious versions you can include [`readable-stream`](https://github.com/isaacs/readable-stream)\nin your depencies, which provides a polyfill.\n\n### Setting up Pickup\n\nWhen choosing `Pickup` all e-mails will be stored in a directory so that they can be picked up by your SMTP server.\n\nPossible options are the following:\n\n * **directory** - The directory where applications save e-mail for later processing by the SMTP server (required)\n\nExample:\n\n```javascript\nvar transport = nodemailer.createTransport(\"PICKUP\", {\n    directory: \"C:\\\\inetpub\\\\mailroot\\\\Pickup\"\n});\n```\n\nor the shorthand version:\n\n```javascript\nvar transport = nodemailer.createTransport(\"PICKUP\", \"C:\\\\inetpub\\\\mailroot\\\\Pickup\");\n```\n\n### Setting up Direct transport\n\n*Direct* transport is useful when you can not or want not to use a relaying service or the sendmail command.\n\nTo set it up, you do not need to provide anything, just run the following to create a transport object:\n\n```\nvar transport = nodemailer.createTransport();\n```\n\nIf you want to use debug logging, use the following form:\n\n```\nvar transport = nodemailer.createTransport(\"direct\", {debug: true});\n```\n\nThere is also a shorthand method `mail` if you do not like to set up a transport object (see [E-mail message fields](#e-mail-message-fields) for options for the `mailOptions` object).\n\n```javascript\nvar mail = require(\"nodemailer\").mail;\nmail(mailOptions);\n```\n\n*Direct* can be quite inefficient as it queues all e-mails to be sent into memory. Additionally, if a message is not yet sent and the process is closed, all data about queued messages are lost. Thus *direct* is only suitable for low throughput systems, like password remainders and such, where the message can be processed immediatelly.\n\n*Direct* is able to handle sending errors, graylisting and such. If a message can not be sent, it is requeued and retried later.\n\nTo raise the odds of getting your emails into recipients inboxes, you should setup [SPF records](http://en.wikipedia.org/wiki/Sender_Policy_Framework) for your domain. Using [DKIM](#dkim-signing) wouldn't hurt either. Dynamic IP addresses are frequently treated as spam sources, so using static IPs is advised.\n\n#### Handling responses\n\n*Direct* exposes an event emitter for receiving status updates. If the message includes several recipients, the message\nis not sent to everyone at once but is sharded in chunks based on the domain name of the addresses. For example\nif your message includes the following recipients: *user1@example.com*, *user2@example.com* and *user3@blurdybloop.com*, then 2 separate messages are sent out - one for *user1@example.com* and *user2@example.com* and one for *user3@blurdybloop.com*. This means that sending to different recipients may succeed or fail independently. All information about messages being delivered, failed or requeued is emitted by the status emitter `statusHandler`.\n\n*Direct* exposes the following events:\n\n  * **'sent'** - message was sent successfully\n  * **'failed'** - message was failed permanently\n  * **'requeue'** - message failed but the error might not be permanent, so the message is requeued for later (once the message is retried an event is fired again).\n\nAll events get the same argument which is an object with the following properties:\n\n  * **domain** - is the domain part of the e-mail addresses\n  * **response** - is the last line form the SMTP transmission\n\n**Usage example**\n\n```javascript\ntransport.sendMail(messageOptions, function(error, response){\n    if(error){\n        console.log(error);\n        return;\n    }\n\n    // response.statusHandler only applies to 'direct' transport\n    response.statusHandler.once(\"failed\", function(data){\n        console.log(\n          \"Permanently failed delivering message to %s with the following response: %s\",\n          data.domain, data.response);\n    });\n\n    response.statusHandler.once(\"requeue\", function(data){\n        console.log(\"Temporarily failed delivering message to %s\", data.domain);\n    });\n\n    response.statusHandler.once(\"sent\", function(data){\n        console.log(\"Message was accepted by %s\", data.domain);\n    });\n});\n```\n\n**NB!** If you want to provide instant feedback to the user, listen for the first `'sent'`, `'failed'`, or `'requeued'` event only. The first event should arrive quickly but once the message gets requeued, the delay until the next event for this particular domain is fired is at least 15 minutes.\n\n> This example uses `.once` for listening to the events which is ok if you have just one recipient. For several recipients with different domains, the events get called several times and thus would need a more complex handling.\n\n#### When would you use Direct transport?\n\n  * When prototyping your application\n  * If you do not have or do not want to use a relaying service account\n  * When running under Windows as a Sendmail replacement (by default Sendmail is not available in Windows)\n\n### DKIM Signing\n\n**Nodemailer** supports DKIM signing with very simple setup. Use this with caution\nthough since the generated message needs to be buffered entirely before it can be\nsigned. Not a big deal with small messages but might consume a lot of RAM when\nusing larger attachments.\n\nSet up the DKIM signing with `useDKIM` method for a transport object:\n\n```javascript\ntransport.useDKIM(dkimOptions)\n```\n\nWhere `dkimOptions` includes necessary options for signing\n\n  * **domainName** - the domainname that is being used for signing\n  * **keySelector** - key selector. If you have set up a TXT record with DKIM public key at *zzz._domainkey.blurdybloop.com* then `zzz` is the selector\n  * **privateKey** - DKIM private key that is used for signing as a string\n  * **headerFieldNames** - optional colon separated list of header fields to sign, by default all fields suggested by RFC4871 #5.5 are used\n\nAll messages transmitted through this transport objects are from now on DKIM signed.\n\nCurrently if several header fields with the same name exists, only the last one (the one in the bottom) is signed.\n\nExample:\n\n```javascript\nvar transport = nodemailer.createTransport(\"Sendmail\");\n\ntransport.useDKIM({\n    domainName: \"kreata.ee\",\n    keySelector: \"dkim\",\n    privateKey: fs.readFileSync(\"private_key.pem\")\n});\n\ntransport.sendMail(mailOptions);\n```\n\nSee [examples/example_dkim.js](https://github.com/andris9/Nodemailer/blob/master/examples/example_dkim.js) for a complete example.\n\n### Well known services for SMTP\n\nIf you want to use a well known service as the SMTP host, you do not need\nto enter the hostname or port number, just use the `service` parameter\n\nCurrently supported services are:\n\n  * **DynectEmail**\n  * **Gmail**\n  * **hot.ee**\n  * **Hotmail**\n  * **iCloud**\n  * **mail.ee**\n  * **Mail.Ru**\n  * **Mailgun**\n  * **Mailjet**\n  * **Mandrill**\n  * **Postmark**\n  * **QQ**\n  * **QQex** (Tencent Business Email)\n  * **SendGrid**\n  * **SES**\n  * **Yahoo**\n  * **yandex**\n  * **Zoho**\n\nPredefined service data covers `host`, `port` and secure connection settings,\nany other parameters (ie. `auth`) need to be set separately. Service names are\ncase insensitive, so using \"gmail\" instead of \"Gmail\" is totally fine.\n\nExample:\n\n```javascript\nvar smtpTransport = nodemailer.createTransport(\"Gmail\",{\n    auth: {\n        user: \"gmail.user@gmail.com\",\n        pass: \"userpass\"\n    }\n});\n```\n\nor alternatively\n\n```javascript\nvar smtpTransport = nodemailer.createTransport(\"SMTP\",{\n    service: \"Gmail\", // sets automatically host, port and connection security settings\n    auth: {\n        user: \"gmail.user@gmail.com\",\n        pass: \"userpass\"\n    }\n});\n```\n\nActually, if you are authenticating with an e-mail address that has a domain name\nlike @gmail.com or @yahoo.com etc., then you don't even need to provide the service name,\nit is detected automatically.\n\n```javascript\nvar smtpTransport = nodemailer.createTransport(\"SMTP\",{\n    auth: {\n        user: \"gmail.user@gmail.com\", // service is detected from the username\n        pass: \"userpass\"\n    }\n});\n```\n\n## E-mail message fields\n\nThe following are the possible fields of an e-mail message:\n\n  - **from** - The e-mail address of the sender. All e-mail addresses can be plain `sender@server.com` or formatted `Sender Name <sender@server.com>`\n  - **to** - Comma separated list or an array of recipients e-mail addresses that will appear on the `To:` field\n  - **cc** - Comma separated list or an array of recipients e-mail addresses that will appear on the `Cc:` field\n  - **bcc** - Comma separated list or an array of recipients e-mail addresses that will appear on the `Bcc:` field\n  - **replyTo** - An e-mail address that will appear on the `Reply-To:` field\n  - **inReplyTo** - The message-id this message is replying\n  - **references** - Message-id list\n  - **subject** - The subject of the e-mail\n  - **text** - The plaintext version of the message\n  - **html** - The HTML version of the message\n  - **generateTextFromHTML** - if set to true uses HTML to generate plain text body part from the HTML if the text is not defined\n  - **headers** - An object of additional header fields `{\"X-Key-Name\": \"key value\"}` (NB! values are passed as is, you should do your own encoding to 7bit and folding if needed)\n  - **attachments** - An array of attachment objects.\n  - **alternatives** - An array of alternative text contents (in addition to text and html parts)\n  - **envelope** - optional SMTP envelope, if auto generated envelope is not suitable\n  - **messageId** - optional Message-Id value, random value will be generated if not set. Set to false to omit the Message-Id header\n  - **date** - optional Date value, current UTC string will be used if not set\n  - **encoding** - optional transfer encoding for the textual parts (defaults to \"quoted-printable\")\n  - **charset** - optional output character set for the textual parts (defaults to \"utf-8\")\n  - **dsn** - An object with methods `success`, `failure` and `delay`. If any of these are set to true, DSN will be used\n\nAll text fields (e-mail addresses, plaintext body, html body) use UTF-8 as the encoding.\nAttachments are streamed as binary.\n\nExample:\n\n```javascript\nvar transport = nodemailer.createTransport(\"Sendmail\");\n\nvar mailOptions = {\n    from: \"me@tr.ee\",\n    to: \"me@tr.ee\",\n    subject: \"Hello world!\",\n    text: \"Plaintext body\"\n}\n\ntransport.sendMail(mailOptions);\n```\n\n### SendGrid support\n\nNodemailer supports SendGrid [SMTP API](http://docs.sendgrid.com/documentation/api/smtp-api/) out of the box - you can\nuse objects as header values and these are automatically JSONized (and mime encoded if needed).\n\n```javascript\nvar mailOptions = {\n    ...,\n    headers: {\n        'X-SMTPAPI': {\n            category : \"newuser\",\n            sub:{\n                \"%name%\": [\"Žiguli Õllepruul\"]\n            }\n        }\n    },\n    subject: \"Hello, %name%\"\n}\n```\n\nThis also applies to any other service that expects a JSON string as a header value for specified key.\n\n### Generate Text from HTML\n\nIf `generateTextFromHTML` option is set to true, then HTML contents of the mail is automatically converted\nto plaintext format when plaintext content is empty or missing.\n\nFor example\n\n```javascript\nmailOptions = {\n    ...,\n    generateTextFromHTML: true,\n    html: '<h1>Hello world</h1><p><b>How</b> are you?',\n    // text: '' // no text part\n}\n```\n\nis automatically converted in the backround by Nodemailer to:\n\n```javascript\nmailOptions = {\n    ...,\n    // source html:\n    html: '<h1>Hello world</h1><p><b>How</b> are you?',\n    // automatically generated plaintext message:\n    text: \"Hello world\\n\"+\n          \"===========\\n\"+\n          \"\\n\"+\n          \"**How** are you?\"\n}\n```\n\nAs you can see the output syntax for `generateTextFromHTML` looks similar to markdown, and that\nis exactly the case here - Nodemailer includes a simple HTML to markdown converter. But don't\nexpect too much from it, it's not full featured or perfect, just some regexes here and there.\n\n### Attachment fields\n\nAttachment object consists of the following properties:\n\n  * **fileName** - filename to be reported as the name of the attached file, use of unicode is allowed (except when using Amazon SES which doesn't like it)\n  * **cid** - optional content id for using inline images in HTML message source\n  * **contents** - String or a Buffer contents for the attachment\n  * **filePath** - path to a file or an URL if you want to stream the file instead of including it (better for larger attachments)\n  * **streamSource** - Stream object for arbitrary binary streams if you want to stream the contents (needs to support *pause*/*resume*)\n  * **contentType** - optional content type for the attachment, if not set will be derived from the `fileName` property\n  * **contentDisposition** - optional content disposition type for the attachment, defaults to \"attachment\"\n\nOne of `contents`, `filePath` or `streamSource` must be specified, if none is\npresent, the attachment will be discarded. Other fields are optional.\n\nAttachments can be added as many as you want.\n\n```javascript\nvar mailOptions = {\n    ...\n    attachments: [\n        {   // utf-8 string as an attachment\n            fileName: \"text1.txt\",\n            contents: \"hello world!\"\n        },\n        {   // binary buffer as an attachment\n            fileName: \"text2.txt\",\n            contents: new Buffer(\"hello world!\",\"utf-8\")\n        },\n        {   // file on disk as an attachment\n            fileName: \"text3.txt\",\n            filePath: \"/path/to/file.txt\" // stream this file\n        },\n        {   // fileName and content type is derived from filePath\n            filePath: \"/path/to/file.txt\"\n        },\n        {   // stream as an attachment\n            fileName: \"text4.txt\",\n            streamSource: fs.createReadStream(\"file.txt\")\n        },\n        {   // define custom content type for the attachment\n            fileName: \"text.bin\",\n            contents: \"hello world!\",\n            contentType: \"text/plain\"\n        },\n        {   // use URL as an attachment\n            fileName: \"license.txt\",\n            filePath: \"https://raw.github.com/andris9/Nodemailer/master/LICENSE\"\n        }\n    ]\n}\n```\n\n### Alternative fields\n\nIn addition to text and HTML, any kind of data can be inserted as an alternative content of the main body - for example a word processing document with the same text as in the HTML field. It is the job of the e-mail client to select and show the best fitting alternative to the reader.\n\nAttahcment object consists of the following properties:\n\n  * **contents** - String or a Buffer contents for the attachment\n  * **contentType** - optional content type for the attachment, if not set will be set to \"application/octet-stream\"\n  * **contentEncoding** - optional value of how the data is encoded, defaults to \"base64\"\n\nIf `contents` is empty, the alternative will be discarded. Other fields are optional.\n\n**Usage example:**\n\n```javascript\nvar mailOptions = {\n    ...\n    html: \"<b>Hello world!</b>\",\n    alternatives: [\n        {\n            contentType: \"text/x-web-markdown\",\n            contents: \"**Hello world!**\"\n        }\n    ]\n}\n```\nIf the receiving e-mail client can render messages in Markdown syntax as well, it could prefer\nto display this alternative as the main content of the message instead of the html part.\n\nAlternatives can be added as many as you want.\n\n### Address Formatting\n\nAll the e-mail addresses can be plain e-mail address\n\n```\nfoobar@blurdybloop.com\n```\n\nor with formatted name (includes unicode support)\n\n```\n\"Ноде Майлер\" <foobar@blurdybloop.com>\n```\n\nTo, Cc and Bcc fields accept comma separated list of e-mails or an array of\nemails or an array of comma separated list of e-mails - use it as you like.\nFormatting can be mixed.\n\n```\n...,\nto: 'foobar@blurdybloop.com, \"Ноде Майлер\" <bar@blurdybloop.com>, \"Name, User\" <baz@blurdybloop.com>',\ncc: ['foobar@blurdybloop.com', '\"Ноде Майлер\" <bar@blurdybloop.com>, \"Name, User\" <baz@blurdybloop.com>']\n...\n```\n\nYou can even use unicode domain and user names, these are automatically converted\nto the supported form\n\n```\n\"Unicode Domain\" <info@müriaad-polüteism.info>\n```\n\n### SMTP envelope\n\nSMTP envelope is usually auto generated from `from`, `to`, `cc` and `bcc` fields but\nif for some reason you want to specify it yourself, you can do it with `envelope` property.\n\n`envelope` is an object with the following params: `from`, `to`, `cc` and `bcc` just like\nwith regular mail options. You can also use the regular address format, unicode domains etc.\n\n```javascript\nmailOptions = {\n    ...,\n    from: \"mailer@kreata.ee\",\n    to: \"daemon@kreata.ee\",\n    envelope: {\n        from: \"Daemon <deamon@kreata.ee>\",\n        to: \"mailer@kreata.ee, Mailer <mailer2@kreata.ee>\"\n    }\n}\n```\n\nThe envelope only applies when using SMTP or sendmail, setting envelope has no effect with SES.\n\n### Using Embedded Images\n\nAttachments can be used as embedded images in the HTML body. To use this\nfeature, you need to set additional property of the attachment - `cid` (unique\nidentifier of the file) which is a reference to the attachment file. The same\n`cid` value must be used as the image URL in HTML (using `cid:` as the URL\nprotocol, see example below).\n\n**NB!** the cid value should be as unique as possible!\n\n```javascript\nvar mailOptions = {\n    ...\n    html: \"Embedded image: <img src='cid:unique@kreata.ee' />\",\n    attachments: [{\n        filename: \"image.png\",\n        filePath: \"/path/to/file\",\n        cid: \"unique@kreata.ee\" //same cid value as in the html img src\n    }]\n}\n```\n\n**Automatic embedding images**\n\nIf you want to convert images in the HTML to embedded images automatically, you can\nset mail option `forceEmbeddedImages` to true. In this case all images in\nthe HTML that are either using an absolute URL (http://...) or absolute file path\n(/path/to/file) are replaced with embedded attachments.\n\nFor example when using this code\n\n```javascript\nvar mailOptions = {\n    forceEmbeddedImages: true\n    html: 'Embedded image: <img src=\"http://example.com/image.png\">'\n};\n```\n\nThe image linked is fetched and added automatically as an attachment and the url\nin the HTML is replaced automatically with a proper `cid:` string.\n\n## Return callback\n\nReturn callback gets two parameters\n\n  * **error** - an error object if the message failed\n  * **responseStatus** - an object with some information about the status on success\n    * **responseStatus.messageId** - message ID used with the message\n\n> Different transport methods may expose additional properties to the `responseStatus` object, eg. *direct* transport exposes `statusHandler`, see the docs for the particular transport type for more info.\n\nExample:\n\n```javascript\nnodemailer.sendMail(mailOptions, function(error, responseStatus){\n    if(!error){\n        console.log(responseStatus.message); // response from the server\n        console.log(responseStatus.messageId); // Message-ID value used\n    }\n});\n```\n\n**NB!** Message-ID used might not be the same that reaches recipients inbox since some providers (like **SES**) may change the value.\n\n\n## Custom Transport Methods\n\nIf you want to use a custom transport method you need to define a constructor function with the following API\n\n```javascript\nfunction MyCustomHandler(options){}\nMyCustomHandler.prototype.sendMail = function(emailMessage, callback){};\nMyCustomHandler.prototype.close = function(closeCallback){};\n```\n\nWhere\n\n  * `options` is the optional options object passed to `createTransport`\n  * `sendMail()` is the function that is going to deliver the message\n  * `emailMessage` is a paused [MailComposer](https://github.com/andris9/mailcomposer#create-a-new-mailcomposer-instance) object. You should call `emailMessage.streamMessage()` once you have everything set up for streaming the message\n  * `callback` is the function to run once the message has been sent or an error occurred. The response object *should* include `messageId` property (you can get the value from `emailMessage._messageId`)\n  * `close()` is an optional method (no need to define it) to close the transport method\n  * `closeCallback` is the function to run once the transport method is closed\n\n### Example usage\n\n```javascript\nvar nodemailer = require(\"nodemailer\");\n// Pipes all messages to stdout\nfunction MyTransport(options){\n    this.options = options;\n}\nMyTransport.prototype.sendMail = function(emailMessage, callback) {\n    console.log(\"Envelope: \", emailMessage.getEnvelope());\n    emailMessage.pipe(process.stdout);\n    emailMessage.on(\"error\", function(err){\n        callback(err);\n    });\n    emailMessage.on(\"end\", function(){\n        callback(null, {\n            messageId: emailMessage._messageId\n        });\n    });\n    // everything set up, start streaming\n    emailMessage.streamMessage();\n};\n// Use MyTransport as the transport method\nvar transport = nodemailer.createTransport(MyTransport, {\n    name: \"my.host\" // hostname for generating Message-ID values\n});\ntransport.sendMail({\n    from: \"sender@example.com\",\n    to: \"receiver@example.com\",\n    subject: \"hello\",\n    text: \"world\"\n}, function(err, response){\n    console.log(err || response);\n});\n```\n\n## Command line usage\n\n**NB!** Command line usage was removed from v0.4\n\n## Tests\n\nRun the tests with npm in Nodemailer's directory\n\n```\nnpm test\n```\n\nThere aren't currently many tests for Nodemailer but there are a lot of tests\nin the modules that are used to generate the raw e-mail body and to use the\nSMTP client connection.\n\n## Tweaking\n\nNodemailer in itself is actually more like a wrapper for my other modules\n[mailcomposer](https://github.com/andris9/mailcomposer) for composing the raw message stream\nand [simplesmtp](https://github.com/andris9/simplesmtp) for delivering it, by providing an\nunified API. If there's some problems with particular parts of the\nmessage composing/sending process you should look at the  appropriate module.\n\n## License\n\n**Nodemailer** is licensed under [MIT license](https://github.com/andris9/Nodemailer/blob/master/LICENSE). Basically you can do whatever you want to with it.\n\n[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/andris9/nodemailer/trend.png)](https://bitdeli.com/free \"Bitdeli Badge\")\n",
  "readmeFilename": "README.md",
  "bugs": {
    "url": "https://github.com/andris9/nodemailer/issues"
  },
  "_id": "nodemailer@0.6.0",
  "dist": {
    "shasum": "02a9b9981df653f77a92b0d1c68eaad6268e40e2"
  },
  "_from": "nodemailer@",
  "_resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-0.6.0.tgz"
}
