You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
pac-auth/test/testsend.js

45 lines
1.6 KiB

// | ------------------------------------------------------------
// | @版本: version 0.1
// | @创建人: 【Nie-x7129】
// | @E-mail: x71291@outlook.com
// | @所在项目: pac-auth
// | @文件描述: testsend.js -
// | @创建时间: 2024-05-14 18:18
// | @更新时间: 2024-05-14 18:18
// | @修改记录:
// | -*-*-*- (时间--修改人--修改说明) -*-*-*-
// | =
// | ------------------------------------------------------------
import * as nodemailer from 'nodemailer';
const transporter = nodemailer.createTransport({
//node_modules/nodemailer/lib/well-known/services.json 查看相关的配置,如果使用qq邮箱,就查看qq邮箱的相关配置
host: 'smtp.qq.com',
// secureConnection:true,
service: 'qq', //类型qq邮箱
// port: 465,
secure: true, // true for 465, false for other ports
auth: {
user: 'togy.gc@qq.com', // 发送方的邮箱
pass: 'iampaqukfwnxdhfd', // smtp 的授权码
},
//pass 不是邮箱账户的密码而是stmp的授权码(必须是相应邮箱的stmp授权码)
//邮箱---设置--账户--POP3/SMTP服务---开启---获取stmp授权码
});
const mailOptions = {
from: '"TOGY | 心曲Tune" <togy.gc@qq.com>', // 发送方
to: 'xsax@qqqq.com', //接收者邮箱,多个邮箱用逗号间隔
subject: 'ABC', // 标题
text: 'Hello world?', // 文本内容
html: 'xsxsx',
};
transporter.sendMail(mailOptions, (error, info) => {
if (error) {
console.log(error);
} else {
console.log('OK'); //因为是异步 所有需要回调函数通知成功结果
}
});