This bot was created to send happy email messages to my Mom at set times throughout the day and year.
At 9, noon and 6pm, different greetings will be sent to my mom.
I have also created a message to remind my mom to drink water. That goes out every day at 1pm.
Inside the messages.js
and holiday-messsages.js
file, I have created all of the variables for the messages.
The bot also sends out messages once a year on Christmas, Valentines Day and New Year's Day.
https://docs.github.com/en/get-started/quickstart/fork-a-repo
- In your terminal, run
git clone https://github.com/YOUR-GITHUB-USERNAME/Happy_Messages_Bot.git
. - In your terminal, under the project directory, run
npm install
to add thenode_modules
folder - In your terminal, under the project directory, run
touch .env
. Store these variables inside the file with our own email address, password and mom's email.
ADMIN_EMAIL = YOUR EMAIL ADDRESS
ADMIN_PASSWORD = YOUR PASSWORD
MOM_EMAIL = YOUR MOM'S EMAIL
- In your terminal, run
npm start
If you want to test sending your own message, then run this code.
//this runs every minute after the server starts
nodeCron.schedule('* * * * *', () => {
async function testingMsg() {
let info = await transporter.sendMail({
from: ADMIN_EMAIL, // sender address
to: MOM_EMAIL, // list of receivers
subject: "Just testing", // Subject line
text: "Hello world?", // plain text body
html: "<b>Hello world?</b>", // html text
})
console.log(`Message send: ${info.messageId}`)
}
testingMsg().catch(console.error);
});
Node.js
Express.js
NodeMailer
Node-cron
Nodemon
# ┌────────────── second (optional)
# │ ┌──────────── minute
# │ │ ┌────────── hour
# │ │ │ ┌──────── day of month
# │ │ │ │ ┌────── month
# │ │ │ │ │ ┌──── day of week
# │ │ │ │ │ │
# │ │ │ │ │ │
# * * * * * *