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
31
32
33
34
35
36
37
38
39
40
const nodemailer = require("nodemailer");
const { default: Axios } = require("axios");
function getHoneyedWords() {
var url = "https://chp.shadiao.app/api.php";

return Axios.get(url);
}
async function sendMail(text) {
var user = "1494***9@qq.com";
var pass = "**********";//授权码
var to = "59***4@qq.com";
let transporter = nodemailer.createTransport({
host: "smtp.qq.com",
port: 587,
secure: false,
auth: {
user: user,
pass: pass,
},
});
let info = await transporter.sendMail({
from: `亲爱的老婆<${user}>`,
to: `亲爱的老公<${to}>`,
subject: "亲爱的老公",
text: text,
});
console.log("发送成功");
}
const schedule = require("node-schedule");
schedule.scheduleJob({ hour: 17, minute: 54 }, function () {
console.log("启动任务:" + new Date());
getHoneyedWords().then((res) => {
console.log(res.data);
sendMail(res.data);
});
});
getHoneyedWords().then(res=>{
console.log(res.data)
sendMail(res.data);
})