mirror of
https://github.com/mgerb/mywebsite
synced 2026-01-13 03:02:49 +00:00
updated bunch of file paths and changed the way posts are loaded
This commit is contained in:
68
node_modules/nodemailer/README.md
generated
vendored
68
node_modules/nodemailer/README.md
generated
vendored
@@ -6,13 +6,7 @@ Send e-mails from Node.js – easy as cake!
|
||||
[](http://travis-ci.org/andris9/Nodemailer)
|
||||
<a href="http://badge.fury.io/js/nodemailer"><img src="https://badge.fury.io/js/nodemailer.svg" alt="NPM version" height="18"></a>
|
||||
|
||||
## Upgrade warning
|
||||
|
||||
Do not upgrade Nodemailer from 0.7 or lower to 1.0 as there are breaking changes. You can continue to use the 0.7 branch as long as you like. See the documentation for 0.7 [here](https://github.com/andris9/Nodemailer/blob/0.7/README.md).
|
||||
|
||||
### Migration guide
|
||||
|
||||
See the migration guide from 0.7 to 1.0 [in the 1.0 release blog post](http://www.andrisreinman.com/nodemailer-v1-0/#migrationguide).
|
||||
> **Notice for v0.x users** – Do not upgrade Nodemailer from 0.7 or lower. You can continue to use the 0.7 branch as long as you like. See the documentation for 0.7 [here](https://github.com/andris9/Nodemailer/blob/0.7/README.md).
|
||||
|
||||
## Notes and information
|
||||
|
||||
@@ -41,14 +35,8 @@ This is a complete example to send an e-mail with plaintext and HTML body
|
||||
```javascript
|
||||
var nodemailer = require('nodemailer');
|
||||
|
||||
// create reusable transporter object using SMTP transport
|
||||
var transporter = nodemailer.createTransport({
|
||||
service: 'Gmail',
|
||||
auth: {
|
||||
user: 'gmail.user@gmail.com',
|
||||
pass: 'userpass'
|
||||
}
|
||||
});
|
||||
// create reusable transporter object using the default SMTP transport
|
||||
var transporter = nodemailer.createTransport('smtps://user%40gmail.com:pass@smtp.gmail.com');
|
||||
|
||||
// NB! No need to recreate the transporter object. You can use
|
||||
// the same transporter object for all e-mails
|
||||
@@ -65,13 +53,15 @@ var mailOptions = {
|
||||
// send mail with defined transport object
|
||||
transporter.sendMail(mailOptions, function(error, info){
|
||||
if(error){
|
||||
console.log(error);
|
||||
}else{
|
||||
console.log('Message sent: ' + info.response);
|
||||
return console.log(error);
|
||||
}
|
||||
console.log('Message sent: ' + info.response);
|
||||
|
||||
});
|
||||
```
|
||||
|
||||
You may need to ["Allow Less Secure Apps"](https://www.google.com/settings/security/lesssecureapps) in your gmail account (it's all the way at the bottom). You also may need to ["Allow access to your Google account"](https://accounts.google.com/DisplayUnlockCaptcha)
|
||||
|
||||
See [nodemailer-smtp-transport](https://github.com/andris9/nodemailer-smtp-transport#usage) for SMTP configuration options and [nodemailer-wellknown](https://github.com/andris9/nodemailer-wellknown#supported-services) for preconfigured service names (example uses 'gmail').
|
||||
|
||||
> When using default SMTP transport, then you do not need to define transport type explicitly (even though you can), just provide the SMTP options and that's it. For anything else, see the docs of the particular [transport mechanism](#available-transports).
|
||||
@@ -85,13 +75,14 @@ Install with npm
|
||||
To send e-mails you need a transporter object
|
||||
|
||||
```javascript
|
||||
var transporter = nodemailer.createTransport(transport)
|
||||
var transporter = nodemailer.createTransport(transport[, defaults])
|
||||
```
|
||||
|
||||
Where
|
||||
|
||||
* **transporter** is going to be an object that is able to send mail
|
||||
* **transport** is a transport mechanism. If it is not set [nodemailer-direct-transport](https://github.com/andris9/nodemailer-direct-transport) transport is used. If it is a regular object [nodemailer-smtp-transport](https://github.com/andris9/nodemailer-smtp-transport) is used and the value is passed as SMTP configuration.
|
||||
* **defaults** is an object that defines default values for mail options (available since Nodemailer v1.10.0)
|
||||
|
||||
> You have to create the transporter object only once. If you already have a transporter object you can use it to send mail as much as you like.
|
||||
|
||||
@@ -126,16 +117,21 @@ var transporter = nodemailer.createTransport({
|
||||
user: 'sender@gmail.com',
|
||||
pass: 'password'
|
||||
}
|
||||
}, {
|
||||
// default values for sendMail method
|
||||
from: 'sender@address',
|
||||
headers: {
|
||||
'My-Awesome-Header': '123'
|
||||
}
|
||||
});
|
||||
transporter.sendMail({
|
||||
from: 'sender@address',
|
||||
to: 'receiver@address',
|
||||
subject: 'hello',
|
||||
text: 'hello world!'
|
||||
});
|
||||
```
|
||||
|
||||
> Default SMTP transport is not suitable for large volume of e-mails new SMTP connection is established for every mail sent. Use [nodemailer-smtp-pool](https://github.com/andris9/nodemailer-smtp-pool) if you need to send a large amout of e-mails.
|
||||
> Default SMTP transport is not suitable for large volume of e-mails new SMTP connection is established for every mail sent. Use [nodemailer-smtp-pool](https://github.com/andris9/nodemailer-smtp-pool) if you need to send a large amount of e-mails.
|
||||
>
|
||||
> For sending bulk mail using Nodemailer see the [recommendations below](#delivering-bulk-mail)
|
||||
|
||||
@@ -174,7 +170,10 @@ transporter.sendMail({
|
||||
* **[nodemailer-sendmail-transport](https://github.com/andris9/nodemailer-sendmail-transport)** for piping messages to the *sendmail* command
|
||||
* **[nodemailer-stub-transport](https://github.com/andris9/nodemailer-stub-transport)** is just for returning messages, most probably for testing purposes
|
||||
* **[nodemailer-pickup-transport](https://github.com/andris9/nodemailer-pickup-transport)** for storing messages to pickup folders
|
||||
* **[nodemailer-sparkpost-transport](https://github.com/sparkpost/nodemailer-sparkpost-transport)** for sending messages through SparkPost's Web API
|
||||
* **[nodemailer-sendgrid-transport](https://github.com/sendgrid/nodemailer-sendgrid-transport)** for sending messages through SendGrid's Web API
|
||||
* **[nodemailer-sailthru-transport](https://github.com/rebelmail/nodemailer-sailthru-transport)** for sending messages through Sailthru's Web API
|
||||
* **[nodemailer-mandrill-transport](https://github.com/rebelmail/nodemailer-mandrill-transport)** for sending messages through Mandrill's Web API
|
||||
* *add yours* (see transport api documentation [here](#transports))
|
||||
|
||||
## Available Plugins
|
||||
@@ -182,7 +181,9 @@ transporter.sendMail({
|
||||
* **[nodemailer-markdown](https://github.com/andris9/nodemailer-markdown)** to use markdown for the content
|
||||
* **[nodemailer-dkim](https://github.com/andris9/nodemailer-dkim)** to sign messages with DKIM
|
||||
* **[nodemailer-html-to-text](https://github.com/andris9/nodemailer-html-to-text)** to auto generate plaintext content from html
|
||||
* **[nodemailer-express-handlebars](https://github.com/yads/nodemailer-express-handlebars)** to auto generate html emails from handelbars/mustache templates
|
||||
* **[nodemailer-express-handlebars](https://github.com/yads/nodemailer-express-handlebars)** to auto generate html emails from handlebars/mustache templates
|
||||
* **[nodemailer-plugin-inline-base64](https://github.com/mixmaxhq/nodemailer-plugin-inline-base64)** to convert base64 images to attachments
|
||||
* **[nodemailer-hashcash](https://github.com/andris9/nodemailer-hashcash)** to generate [hashcash](http://www.hashcash.org/) headers
|
||||
* *add yours* (see plugin api documentation [here](#plugin-api))
|
||||
|
||||
## Sending mail
|
||||
@@ -190,13 +191,13 @@ transporter.sendMail({
|
||||
Once you have a transporter object you can send mail
|
||||
|
||||
```javascript
|
||||
transporter.sendMail(data, callback)
|
||||
transporter.sendMail(data[, callback])
|
||||
```
|
||||
|
||||
Where
|
||||
|
||||
* **data** defines the mail content (see [e-mail message fields](#e-mail-message-fields) below)
|
||||
* **callback** is an optional callback function to run once the message is delivered or it failed.
|
||||
* **callback** is an optional callback function to run once the message is delivered or it failed
|
||||
* **err** is the error object if message failed
|
||||
* **info** includes the result, the exact format depends on the transport mechanism used
|
||||
* **info.messageId** most transports *should* return the final Message-Id value used with this property
|
||||
@@ -208,6 +209,8 @@ Where
|
||||
|
||||
> If the message includes several recipients then the message is considered sent if at least one recipient is accepted
|
||||
|
||||
If `callback` argument is not set then the method return a Promise object. Nodemailer itself does not use Promises internally but it wraps the return into a Promise for convenience.
|
||||
|
||||
### E-mail message fields
|
||||
|
||||
The following are the possible fields of an e-mail message:
|
||||
@@ -223,13 +226,15 @@ The following are the possible fields of an e-mail message:
|
||||
- **subject** - The subject of the e-mail
|
||||
- **text** - The plaintext version of the message as an Unicode string, Buffer, Stream or an object *{path: '...'}*
|
||||
- **html** - The HTML version of the message as an Unicode string, Buffer, Stream or an object *{path: '...'}*
|
||||
- **watchHtml** - Apple Watch specific HTML version of the message (*experimental*)
|
||||
- **priority** - Sets message importance headers, either `'high'`, `'normal'` (default) or `'low'`.
|
||||
- **headers** - An object or array of additional header fields (e.g. *{"X-Key-Name": "key value"}* or *[{key: "X-Key-Name", value: "val1"}, {key: "X-Key-Name", value: "val2"}]*)
|
||||
- **attachments** - An array of attachment objects (see [below](#attachments) for details)
|
||||
- **alternatives** - An array of alternative text contents (in addition to text and html parts) (see [below](#alternatives) for details)
|
||||
- **envelope** - optional SMTP envelope, if auto generated envelope is not suitable (see [below](#smtp-envelope) for details)
|
||||
- **messageId** - optional Message-Id value, random value will be generated if not set
|
||||
- **date** - optional Date value, current UTC string will be used if not set
|
||||
- **encoding** - optional transfer encoding for the textual parts (defaults to 'quoted-printable')
|
||||
- **encoding** - optional transfer encoding for the textual parts
|
||||
|
||||
All text fields (e-mail addresses, plaintext body, html body) use UTF-8 as the encoding.
|
||||
Attachments are streamed as binary.
|
||||
@@ -241,11 +246,14 @@ Attachment object consists of the following properties:
|
||||
* **filename** - filename to be reported as the name of the attached file, use of unicode is allowed
|
||||
* **cid** - optional content id for using inline images in HTML message source
|
||||
* **content** - String, Buffer or a Stream contents for the attachment
|
||||
* **encoding** - If set and `content` is string, then encodes the content to a Buffer using the specified encoding. Example values: `base64`, `hex`, 'binary' etc. Useful if you want to use binary attachments in a JSON formatted e-mail object.
|
||||
* **encoding** - If set and `content` is string, then encodes the content to a Buffer using the specified encoding. Example values: `base64`, `hex`, `binary` etc. Useful if you want to use binary attachments in a JSON formatted e-mail object.
|
||||
* **path** - path to a file or an URL (data uris are allowed as well) if you want to stream the file instead of including it (better for larger attachments)
|
||||
* **contentType** - optional content type for the attachment, if not set will be derived from the `filename` property
|
||||
* **contentDisposition** - optional content disposition type for the attachment, defaults to 'attachment'
|
||||
|
||||
> **Warning about stream errors** –
|
||||
> If an error occurs with an input stream, eg. an attachment from an URL fails to load, then message generation is not rejected. Instead, the error message gets written as the attachment contents.
|
||||
|
||||
Attachments can be added as many as you want.
|
||||
|
||||
```javascript
|
||||
@@ -417,7 +425,7 @@ transporter.use(step, pluginFunc)
|
||||
Where
|
||||
|
||||
* **transporter** is a transport object created with `createTransport`
|
||||
* **step** is a string, either 'compile' or 'stream' thatd defines when the plugin should be hooked
|
||||
* **step** is a string, either 'compile' or 'stream' that defines when the plugin should be hooked
|
||||
* **pluginFunc** is a function that takes two arguments: the mail object and a callback function
|
||||
|
||||
## Plugin API
|
||||
@@ -594,15 +602,15 @@ See [minimal-transport.js](examples/minimal-transport.js) for a working example.
|
||||
|
||||
Even though Gmail is the fastest way to get started with sending emails, it is by no means a preferable solution unless you are using OAuth2 authentication. Gmail expects the user to be an actual user not a robot so it runs a lot of heuristics for every login attempt and blocks anything that looks suspicious to defend the user from account hijacking attempts. For example you might run into trouble if your server is in another geographical location – everything works in your dev machine but messages are blocked in production.
|
||||
|
||||
Additionally Gmail has came up with the concept of ['less secure'](https://support.google.com/accounts/answer/6010255?hl=en) apps which is basically anyone who uses plain password to login to Gmail, so you might end up in a situation where one username can send (support for 'less secure' apps is enabled) but other is blocked (support for 'less secure' apps is disabled).
|
||||
Additionally Gmail has came up with the concept of ['less secure'](https://support.google.com/accounts/answer/6010255?hl=en) apps which is basically anyone who uses plain password to login to Gmail, so you might end up in a situation where one username can send (support for 'less secure' apps is enabled) but other is blocked (support for 'less secure' apps is disabled). When using this method make sure to enable the required functionality by completing the "[captcha enable](https://accounts.google.com/b/0/displayunlockcaptcha)". Without this, less secure connections won't work.
|
||||
|
||||
To prevent having login issues you should either use XOAUTH2 (see details [here](https://github.com/andris9/nodemailer-smtp-transport#authentication)) or use another provider and preferably a dedicated one like [Mailgun](http://www.mailgun.com/) or [SendGrid](http://mbsy.co/sendgrid/12237825) or any other. Usually these providers have free plans available that are compareable to the daily sending limits of Gmail. Gmail has a limit of 500 recipients a day (a message with one *To* and one *Cc* address counts as two messages since it has two recipients) for @gmail.com addresses and 2000 for Google Apps customers, larger SMTP providers usually offer about 200-300 recipients a day for free.
|
||||
To prevent having login issues you should either use XOAUTH2 (see details [here](https://github.com/andris9/nodemailer-smtp-transport#authentication)) or use another provider and preferably a dedicated one like [Mailgun](http://www.mailgun.com/) or [SendGrid](http://mbsy.co/sendgrid/12237825) or any other. Usually these providers have free plans available that are comparable to the daily sending limits of Gmail. Gmail has a limit of 500 recipients a day (a message with one *To* and one *Cc* address counts as two messages since it has two recipients) for @gmail.com addresses and 2000 for Google Apps customers, larger SMTP providers usually offer about 200-300 recipients a day for free.
|
||||
|
||||
## Delivering Bulk Mail
|
||||
|
||||
Here are some tips how to handle bulk mail, for example if you need to send 10 million messages at once (originally published as a [blog post](http://www.andrisreinman.com/delivering-bulk-mail-with-nodemailer/)).
|
||||
|
||||
1. **Use a dedicated SMTP provider** like [SendGrid](http://mbsy.co/sendgrid/12237825) or [Mailgun](http://www.mailgun.com/) or any other. Do not use services that offer SMTP as a sideline or for free (thats Gmail or the SMTP of your homepage hosting company) to send bulk mail – you'll hit all the hard limits immediatelly or get labelled as spam. Basically you get what you pay for and if you pay zero then your deliverability is near zero as well. E-mail might seem free but it is only free to a certain amount and that amount certainly does not include 10 million e-mails in a short period of time.
|
||||
1. **Use a dedicated SMTP provider** like [SendGrid](http://mbsy.co/sendgrid/12237825) or [Mailgun](http://www.mailgun.com/) or any other. Do not use services that offer SMTP as a sideline or for free (that's Gmail or the SMTP of your homepage hosting company) to send bulk mail – you'll hit all the hard limits immediatelly or get labelled as spam. Basically you get what you pay for and if you pay zero then your deliverability is near zero as well. E-mail might seem free but it is only free to a certain amount and that amount certainly does not include 10 million e-mails in a short period of time.
|
||||
2. **Use a dedicated queue manager,** for example [RabbitMQ](http://www.rabbitmq.com/) for queueing the e-mails. Nodemailer creates a callback function with related scopes etc. for every message so it might be hard on memory if you pile up the data for 10 million messages at once. Better to take the data from a queue when there's a free spot in the connection pool (previously sent message returns its callback).
|
||||
3. **Use [nodemailer-smtp-pool](https://github.com/andris9/nodemailer-smtp-pool) transport.** You do not want to have the overhead of creating a new connection and doing the SMTP handshake dance for every single e-mail. Pooled connections make it possible to bring this overhead to a minimum.
|
||||
4. **Set `maxMessages` option to `Infinity`** for the nodemailer-smtp-pool transport. Dedicated SMTP providers happily accept all your e-mails as long you are paying for these, so no need to disconnect in the middle if everything is going smoothly. The default value is 100 which means that once a connection is used to send 100 messages it is removed from the pool and a new connection is created.
|
||||
|
||||
Reference in New Issue
Block a user