egg-nodemailer-d
v1.0.0
Published
``` npx cnpm i nodemailer -D ``` ``` npx cnpm i egg-nodemailer -D ```
Downloads
4
Readme
egg-nodemailer
Install
npx cnpm i nodemailer -D
npx cnpm i egg-nodemailer -D
email.js
"use strict";
const nodemailer = require("nodemailer");
// async..await is not allowed in global scope, must use a wrapper
module.exports.faEmail = async(svg) => {
// create reusable transporter object using the default SMTP transport
let transporter = nodemailer.createTransport({
host: "smtp.163.com",
secure: true, // true for 465, false for other ports
auth: {
user: testAccount.user, // generated ethereal user
pass: testAccount.pass, // generated ethereal password
},
});
// send mail with defined transport object
return await transporter.sendMail({
from: '"Fred Foo 👻" <[email protected]>', // sender address
to: "[email protected], [email protected]", // list of receivers
subject: "Hello ✔", // Subject line
text: "Hello world?", // plain text body
html: `<div><svg>${svg.data}</svg><b>${svg.text}</b></div>`, // html body
});
}
//home.js
const { faEmail } = require("../methods/email");
//
faEmail(svg);