-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
34 lines (28 loc) · 1.13 KB
/
index.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
26
27
28
29
30
31
32
33
34
"use strict";
const nodemailer = require("nodemailer");
require('dotenv').config();
// async..await is not allowed in global scope, must use a wrapper
async function main() {
// create reusable transporter object using the default SMTP transport
let transporter = nodemailer.createTransport({
service: "Gmail",
auth: {
user: process.env.GMAIL_USER,
pass: process.env.GMAIL_PASS
}
});
// send mail with defined transport object
let info = await transporter.sendMail({
from: '"Seth Spivey" <[email protected]>', // sender address
to: "[email protected]", // list of receivers
subject: "Hello from NODE.JS", // Subject line
text: "Hello world?", // plain text body
html: "<h1>Hello Header</h1><b>HELLO HERE</b>" // html body
});
console.log("Message sent: %s", info.messageId);
// Message sent: <[email protected]>
// Preview only available when sending through an Ethereal account
console.log("Preview URL: %s", nodemailer.getTestMessageUrl(info));
// Preview URL: https://ethereal.email/message/WaQKMgKddxQDoou...
}
main().catch(console.error);