(QQ邮箱示例)
1.准备两个邮箱号,一发一收。
2.获取QQ邮箱授权码(发送那个)
3.微信接收(QQ邮箱提醒功能)
host / port:配置参考
1.https://github.com/nodemailer/nodemailer/blob/master/lib/well-known/services.json
2.npm install nodemailer
node_modules\nodemailer\lib\well-known\services.json
import cloud from '@lafjs/cloud';
const nodemailer = require("nodemailer");
export async function main(ctx: FunctionContext) {
let send_res = await sendMail("云开发")
.then((res) => { return res })
.catch((err) => { return err });
console.log(send_res.response)
};
async function sendMail(text) {
let transporter = nodemailer.createTransport({
host: "smtp.qq.com",
port: 465,
secure: true,
auth: {
user: "xxxx@qq.com",
pass: "xxxx",
}
});
let info = await transporter.sendMail({
from: "xxxx@qq.com",
to: "xxxx@qq.com",
subject: "来自云函数邮件",
html: "<h1>" + text + "</h1>"
});
return info
};