UNPKG

@tasolutions/express-core

Version:
37 lines (34 loc) 1.01 kB
const transporter = require('nodemailer'); const config = require('../config'); /** * This function sendmail * @param receiver * @param subject * @param text * @param html */ module.exports = function sendMail(receiver, subject, text, html, attachments = []) { // setup nodemailer let smtpTransport = transporter.createTransport({ host: config.nodeMailer.host, port: config.nodeMailer.port, secure: config.nodeMailer.secure, auth: { user: config.nodeMailer.auth.user, pass: config.nodeMailer.auth.pass, }, tls: { rejectUnauthorized: false } }); smtpTransport.sendMail({ from: config.nodeMailer.name + ' <' + config.nodeMailer.from + '>', to: receiver.toString(), // multiple receiver convernt array to string subject, // subject attachments: attachments, text, html, // body }, (error, response) => { smtpTransport.close(); }); };