Fri Jun 2 06:58:00 UTC 2023 inscode

上级 262415d3
......@@ -8,6 +8,7 @@
},
"dependencies": {
"guess": "^1.0.2",
"nodemailer": "^6.9.3",
"vue": "^3.2.37"
},
"devDependencies": {
......
function sendMail () {
// 收件人邮箱
const toEmail = 'example@mail.com';
// 邮件主题
const subject = 'Hello, world!';
// 邮件内容
const content = 'This is a test email.';
// 调用发送邮件的API
sendEmailAPI(toEmail, subject, content);
}
// 引入 nodemailer 模块
const nodemailer = require('nodemailer');
// 定义发送邮件的函数
function sendMail() {
// 设置邮件的收件人,主题和内容
const recipient = 'admin@aresn.com';
const subject = 'Test email';
const message = 'This is a test email';
// 创建一个用于发送邮件的 transporter,这里使用的是 Gmail 服务
const transporter = nodemailer.createTransport({
service: 'gmail',
auth: {
user: 'your-email@gmail.com', // 你的 Gmail 邮箱
pass: 'your-email-password' // 你的 Gmail 邮箱密码
}
});
// 设置邮件的选项,包括发件人,收件人,主题和内容
const mailOptions = {
from: 'your-email@gmail.com', // 你的 Gmail 邮箱
to: recipient,
subject: subject,
text: message
};
// 调用 transporter 的 sendMail 方法发送邮件,根据发送结果输出日志
transporter.sendMail(mailOptions, function (error, info) {
if (error) {
console.log(error);
return false; // 发送失败,返回 false
} else {
console.log('Email sent: ' + info.response);
return true; // 发送成功,返回 true
}
});
}
sendMail();
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册