-
Notifications
You must be signed in to change notification settings - Fork 2
/
sendmail.js
25 lines (23 loc) · 854 Bytes
/
sendmail.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import nodemailer from "nodemailer";
import ReactDOMServer from "react-dom/server";
export default async function sendMail(person, template) {
// create reusable transporter object using the default SMTP transport
let transporter = nodemailer.createTransport({
host: process.env.SMTP_HOST,
port: process.env.SMTP_PORT,
secure: true,
auth: {
user: process.env.SES_USERNAME,
pass: process.env.SES_PASSWORD
}
});
// send mail with defined transport object
let info = await transporter.sendMail({
from: `${process.env.NEXT_PUBLIC_ADMIN_NAME} from ListTweet [email protected]`,
to: person.email,
bcc: process.env.NEXT_PUBLIC_ADMIN_EMAIL,
subject: "Update from ListTweet",
html: ReactDOMServer.renderToStaticMarkup(template)
});
console.log(`Email report sent to: ${person.screenName}`);
}