I am trying to setup an email reminder using Node-schedule and 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.
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!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.