-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use sengrid account on nodemailer test (#3517)
- Loading branch information
1 parent
979e999
commit 3a93ddf
Showing
2 changed files
with
15 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 9 additions & 12 deletions
21
test/js/third_party/nodemailer/process-nodemailer-fixture.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,20 @@ | ||
import nodemailer from "nodemailer"; | ||
const account = await nodemailer.createTestAccount(); | ||
const nodemailer = require("nodemailer"); | ||
const transporter = nodemailer.createTransport({ | ||
host: account.smtp.host, | ||
port: account.smtp.port, | ||
secure: account.smtp.secure, | ||
host: "smtp.sendgrid.net", | ||
port: 587, | ||
secure: false, | ||
auth: { | ||
user: account.user, // generated ethereal user | ||
pass: account.pass, // generated ethereal password | ||
user: "apikey", // generated ethereal user | ||
pass: process.env.SMTP_SENDGRID_KEY, // generated ethereal password | ||
}, | ||
}); | ||
|
||
// send mail with defined transport object | ||
let info = await transporter.sendMail({ | ||
from: '"Fred Foo 👻" <[email protected]>', // sender address | ||
to: "[email protected]", // list of receivers | ||
from: process.env.SMTP_SENDGRID_SENDER, // sender address | ||
to: process.env.SMTP_SENDGRID_SENDER, // list of receivers | ||
subject: "Hello ✔", // Subject line | ||
text: "Hello world?", // plain text body | ||
html: "<b>Hello world?</b>", // html body | ||
}); | ||
const url = nodemailer.getTestMessageUrl(info); | ||
console.log(typeof url === "string" && url.length > 0); | ||
transporter.close(); | ||
console.log(typeof info?.messageId === "string"); |