Member-only story

Cron Job Email Sending with Node JS

Nonimi
5 min readJun 15, 2023

--

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

  1. 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…

--

--

Nonimi
Nonimi

Written by Nonimi

Thinking about my mind itself is the a great thing. Meanwhile opportunity to be a part of developing soft(ware) world is great. However, thinking about society?

No responses yet