Member-only story
Email Reminder Script in Nodejs (with code)
2 min readJun 21, 2025
Press enter or click to view image in full size![]()
1. Cron Job: Automatically run the script daily
2. Frontend Dashboard: View, add, and manage tasks
First : Cron Job Setup
We’ll use node-cron to run the email reminder every day at 9 AM.
📄 Update reminder.js:
const fs = require('fs');
const nodemailer = require('nodemailer');
const cron = require('node-cron');
// Load tasks
function loadTasks() {
return JSON.parse(fs.readFileSync('tasks.json'));
}
// Email config
const transporter = nodemailer.createTransport({
service: 'gmail',
auth: {
user: 'your.email@gmail.com',
pass: 'your_app_password_here'
}
});
function sendReminderEmail(task) {
const mailOptions = {
from: 'your.email@gmail.com',
to: task.email,
subject: `Task Reminder: ${task.title}`,
text: `Hi! Just a reminder that your task "${task.title}" is due today.`
};
transporter.sendMail(mailOptions, (err, info) => {
if (err) console.error('Email error:', err);
else console.log(`Reminder sent to ${task.email}`);
});
}
function checkDueTasks() {
const today = new Date().toISOString().slice(0, 10);
const tasks = loadTasks();
tasks.forEach(task => {
if (task.dueDate === today) sendReminderEmail(task);
});
}
// Cron: runs every day at 9 AM
cron.schedule('0 9 * * *', () => {…




