import mailer from '../../server/core/mailer';
mailer.init({
sender: 'Test Bot <[email protected]>',
driver: 'gmail',
interval: 2000,
attachLimit: {
txt: 1000,
jpeg: 20000000
}
});
Possible options values:
- sender (Required) String - set field 'from' for sended emails
- driver (Required) String - name of email driver
- interval (Required) String - set interval time for sync with email service for parse list of mails
- attachLimit (Required) Object - set allowed types and their max size
Start server and watch for new emails.
let timerId = mailer.start();
Stop server and unwatch for new emails.
mailer.stop(timerId);
mailer.on('message', (mail) => {
console.log(mail);
});
mailer.send(
{
subject: 'some subject',
message: 'some message',
to: ['[email protected]'],
attachments:
[{
name: 'picture.jpeg',
attach: 'https://static.pexels.com/photos/96918/pexels-photo-96918.jpeg',
type: 'url'
}],
date: Date.now()
});
Possible options values:
- subject (Required) String - email subject
- message (Required) String - email message
- to (Required) String or Array - email recipient or list of recipients
- attachments (Optional) Array - email attachments
- date (Required) Date(UTC) - date for delayed sending email
- sender (Optional) String - update field 'from' for sended emails
Add your count to type that you want to set.
date: mailer.setSendedData({ seconds: dateNow.getSeconds() + 7 })
Possible param values:
- year
- month
- date
- hours
- minutes
- seconds