[英]node-schedule not working with send at specific date rule
I am trying to setup an email reminder using Node-schedule and nodemailer.我正在尝试使用 Node-schedule 和 nodemailer 设置电子邮件提醒。
Basically my application needs to send two emails... one immediately when the module is called, and one at a specific date.基本上,我的应用程序需要发送两封电子邮件……一封在模块被调用时立即发送,另一封在特定日期发送。
For now I just chose a random date for testing, but I am not able to receive the scheduled mail.目前我只是选择了一个随机日期进行测试,但我无法收到预定的邮件。
I can confirm that the emails work just fine as I am able to receive them when sent instantly, the date specified node scheduler does not work however.我可以确认电子邮件工作正常,因为我能够在立即发送时收到它们,但是指定日期的节点调度程序不起作用。
Just FYI: I tested to make sure my server is running at the same time as I am, and I am inputing 24hour date format.仅供参考:我进行了测试以确保我的服务器与我同时运行,并且我输入的是 24 小时日期格式。
var schedule = require('node-schedule');
module.exports = function (jobData) {
var nodemailer = require('nodemailer');
var smtpTransport = nodemailer.createTransport
('smtps://emailname%40gmail.com:somepassword@smtp.gmail.com');
function callTransporter(emailData) {
smtpTransport.sendMail(emailData, function (error, info) {
if (error) {
return console.log(error);
}
console.log('Message sent: ' + info.response);
});
}
function interviewReminderEmail(emailData) {
var mailOptions = {
from: '"Job Seeker" <donotreply@fdsfsdf.com>',
to: 'someperson@gmail.com',
subject: 'Interview coming up! ✔',
text: 'some message',
html: '<b>blablabla</b>'
};
var interviewDate = new Date(2016, 4, 30, 15, 30, 0);
//region of code where I setup scheduled email.
// I get no errors, however it is not sending an email either.
var j = schedule.scheduleJob(interviewDate, function () {
console.log('Sending interview reminder Email.');
callTransporter(mailOptions);
});
}
interviewReminderEmail(jobData);
} }
我想我明白了,四月是 3,因为一月从 0 开始。doh!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.