Skip to content

Commit

Permalink
refactor: Minor cleanup of sendMail call.
Browse files Browse the repository at this point in the history
Signed-off-by: Johannes Tegnér <[email protected]>
  • Loading branch information
Johannestegner committed Nov 2, 2020
1 parent 9ee2471 commit 1911a8c
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Plugin } from '@jitesoft/yolog';
import nodemailer from 'nodemailer';

export default class Email extends Plugin {
/** @var {Mailer[]} */
/** @var {Mail[]} */
#transporters = [];
#recipients = [];
#sender = '';
Expand Down Expand Up @@ -69,7 +69,7 @@ export default class Email extends Plugin {
* @param {Array<String>} recipients Recipients email addresses as array.
* @param {String} sender Sender email address, can be in the form of `Name <[email protected]>` if wanted..
* @param {String} subject Subject template, see setTextTemplate or setHtmlTemplate for parameter values.
* @param {Array<Mailer>|Array<Object>} transports Nodemailer transporters as array.
* @param {Array<Mail>|Array<Object>} transports Nodemailer transporters as array.
*/
constructor (recipients = [], sender = 'yolog-email-plugin@localhost', subject = '{TAG} - {DATETIME}', transports = []) {
super();
Expand Down Expand Up @@ -129,14 +129,12 @@ export default class Email extends Plugin {
}

static #sendMail = async (sender, recipients, subject, text, html, transport) => {
return new Promise((resolve, reject) => {
transport.sendMail({
from: sender,
to: recipients,
subject: subject,
text: text,
html: html
}, (err, info) => err ? reject(err) : resolve(info));
return transport.sendMail({
from: sender,
to: recipients,
subject: subject,
text: text,
html: html
});
};
}
}

0 comments on commit 1911a8c

Please sign in to comment.