Member-only story
Today I would like to share with you my amazing experience with cron and NodeJS. First of all, I will tell you what the npm packages used to send emails are in the scheduling time. We need some npm packages for scheduling emails and sending emails. And another thing: I sent an Excel sheet attachment with my email, so I used another npm package to write my data in an Excel sheet. We go through those things step by step. So, let’s start, full of curious folks.
Install npm packages
To send emails, use node-mailer.
npm i nodemailer
To schedule email sending job, use node-cron.
npm i node-cron
To data compile in to CSV file, use csv-writer.
npm i csv-writer
How to set up an email service provider
- Create a new JavaScript file (e.g.,
sendEmail.js
) and require the Nodemailer module:
const nodemailer = require('nodemailer');
2. Set up the transporter object with the email service provider details and authentication:
const transporter = nodemailer.createTransport({
service: 'your_email_service_provider', // e.g., 'Gmail'
auth: {
user: 'your_email_address',
pass…