Reputation: 584
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:[email protected]');
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" <[email protected]>',
to: '[email protected]',
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);
}
Upvotes: 3
Views: 1102
Reputation: 584
I think I figured it out, the month of April is 3 because January starts at 0. doh!
Upvotes: 3