Created
April 22, 2021 06:28
-
-
Save kuc-arc-f/8575c5e96a9f48d6a217e6397244f7e6 to your computer and use it in GitHub Desktop.
mail send, by nodemailer
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
"use strict"; | |
const nodemailer = require("nodemailer"); | |
var receiverEmailAddress = 'to123@hoge.com' | |
var senderEmailAddress = 'from123@hoge.com' | |
async function smtp_send() { | |
let transporter = nodemailer.createTransport({ | |
host: "smtp.hoge.com", | |
port: 465, | |
secure: true, // true for 465, false for other ports | |
auth: { | |
user: "hoge", // generated ethereal user | |
pass: "1234", // generated ethereal password | |
}, | |
}); | |
// send mail with defined transport object | |
let info = await transporter.sendMail({ | |
from: senderEmailAddress, // sender address | |
to: receiverEmailAddress, // list of receivers | |
subject: "テスト用メールとなります 4", // Subject line | |
text: "テスト用メールとなります 4 BODY", // plain text body | |
html: "<p>テスト用メールとなります 4 HTML</p>", // html body | |
}); | |
console.log("Message sent: %s", info.messageId); | |
console.log("Preview URL: %s", nodemailer.getTestMessageUrl(info)); | |
} | |
// | |
smtp_send().catch(console.error); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment