Send Vinyl files as email.
The first thing to do is to create a Mail stream:
var path = ;var es = ;var Mail = ;var mail =from: processenvSEND_FROMlayout: 'email'template: 'email'viewPath: pathservice: processenvTRANSPORTER_SERVICEauth:user: processenvTRANSPORTER_AUTH_USERpass: processenvTRANSPORTER_AUTH_PASS;
from value is a default, but if omitted will need to be provided when sending each email.
template values indicate which template to use to create the email, and which layout to place that template into. The location of the templates is provided by the
The values in
auth specify which email service to use, and these values are passed to nodemailer.
A typical use of the mail stream would be to provide a destination for a Gulp task. Continuing the example, we'll first create a Vinyl file that contains an email body as its
var gulp = ;var File = ;gulp
Next we augment the file with a
meta property which contains the target email address, the subject of the email, and a
content property which will be passed in to the template processor:
filemeta =to: 'email@example.com'subject: 'Hello!'context:name: 'World';
Now all we need to do is pipe this file to the mail stream's destination, and the file will be sent as an email:
Each successfully sent email emits a
sent event with information about the transaction: