Mailer wrapper for nodejs
npm i larvitmail
Defaults to SMTP localhost without any options.
send()
returns SentMessageInfo
from nodemailer (https://nodemailer.com/usage/)
where messageId, envelope, acceppted, rejected etc. can be found.
const Mail = require('larvitmail');
const mail = new Mail();
await mail.send({
'from': '[email protected]',
'to': '[email protected]',
'subject': 'test',
'text': 'BAM!'
}; // throws on error
console.log('Mail sent');
const Mail = require('larvitmail');
const mail = new Mail({
'log': new require('larvitutils').Log('verbose'),
'transportConf': 'smtps://user%40gmail.com:[email protected]',
'mailDefaults': {
'from': '[email protected]'
}
});
await mail.send({
'to': '[email protected]',
'subject': 'test',
'text': 'BAM!'
};
console.log('Mail sent');
Set "isHtml" to true to use templates to send html emails.
const Mail = require('larvitmail');
const mail = new Mail();
await mail.send({
to: '[email protected]',
subject: 'test',
template: '<h1>Hello <%= name %>!</h1>',
templateData: { 'name': 'bar' },
isHtml: true
};
console.log('Mail sent');
- Replaced callback with promises
- Upped lib versions