-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-smtp.js
More file actions
30 lines (26 loc) · 837 Bytes
/
Copy pathtest-smtp.js
File metadata and controls
30 lines (26 loc) · 837 Bytes
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
// test-smtp.js
import nodemailer from "nodemailer";
import dotenv from "dotenv";
dotenv.config();
async function run(){
const transporter = nodemailer.createTransport({
host: process.env.MAIL_HOST || "smtp.gmail.com",
port: Number(process.env.MAIL_PORT || 587),
secure: (process.env.MAIL_SECURE === "true"), // false -> STARTTLS
auth: {
user: process.env.MAIL_USER,
pass: process.env.MAIL_PASS
}
});
const info = await transporter.sendMail({
from: process.env.MAIL_FROM || process.env.MAIL_USER,
to: "[email protected]", // ここに確認用の受信先を入れる
subject: "[TEST] CryptoPayMap SMTP test",
text: "これが SMTP テストメールです。"
});
console.log("sent:", info);
}
run().catch(e=>{
console.error("failed:", e);
process.exit(1);
});