yamailer - Yet Another Mailer
Simple nodemailer
wrapper.
See ./test
folder for examples.
Accepted options are the same ones accepted by nodemailer
.
Install
npm install yamailer
Import
const yamailer = yam = /* { Optional options object in the nodemailer way } */
Methods
- addAttachment: Add attachment as object. Valid properties are:
yam
- addAttachments: Add array of attachments (see method above)
yam.addAttachments([ ... ])
- addRecipient: Add email recipient (this must be a valid email address)
yam.addRecipient('recipient@example.com')
- addRecipients: Add array of email recipients (array of valid email addresses)
yam.addRecipients(['recipient1@example.com', 'recipient2@example.com'])
- from: specify sender email and name
yam.from('mail@example.com', 'Mail sender name')
- html: specify email HTML contents
yam.html('<h1>Hello World!</h1>')
- options: specify optionsyamoptions// options object in the nodemailer way;
- send: send email (it returns a
<Promise>
)
yam.send()
- subject: specify email subject
yam.subject('What\'s up?!')
- text: specify email plain text contents
yam.subject('Greetings from Malibù!')
Other references
For additional info about nodemailer
input options
: https://www.npmjs.com/package/nodemailer
Full example
npm install yamailer hotenv
const yamailer = hotenv = ;; const yam = username = processenvGMAIL_USERNAME password = processenvGMAIL_PASSWORD recipient = processenvEMAIL_RECIPIENT; yamoptions service: 'gmail' host: 'smtp.gmail.com' auth: user: username pass: password text'test';