Skip to content

cherryblued/mail-queuing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“¬ Express Email Queue with BullMQ, Nodemailer & Redis

PM2 Node.js BullMQ Redis TypeScript


βš™οΈ Tech Stack

  • Express.js – API
  • BullMQ – Queue system
  • Nodemailer – Email sending
  • Redis – Queue storage
  • PM2 – Process manager for worker/API
  • TypeScript – Type-safety

πŸš€ Features

  • βœ… Queue email jobs asynchronously
  • πŸ›‘ Type-safe job structure with TypeScript
  • πŸ“¬ Nodemailer integration
  • πŸ”§ Easily scalable with PM2

πŸ“¦ Installation

git clone https://github.com/luna-zx/mail-queuing.git
cd mail-queuing
npm i

πŸ§ͺ Set Environment Variables

SMTP_HOST = # your SMTP HOST 
SMTP_PORT = # your SMTP PORT
SMTP_USER = # your SMTP USER
SMTP_PASS = # your SMTP PASSWORD

REDIS_HOST = # your REDIS HOST
REDIS_PORT = # your REDIS PORT
REDIS_USER = # your REDIS user
REDIS_PASS =  # your REDIS pass

API_PORT = # your api port

▢️ Start Services

PM2 :

npm run build
npx pm2 start pm2.config.js

Terminals :

# Terminal 1
node dist/server.js 
# or
npx ts-node src/server.ts

# Terminal 2
node dist/worker/emailWorker.js
# or
npx ts-node src/worker/emailWorker.ts

πŸ“¨ Send a Test Email

curl -X POST http://localhost:yourport/send-email \
-H "Content-Type: application/json" \
-d '{ "to": "test@gmail.com", "subject": "Hello from sigma boy", "html": "<p>Test</p>" }'

Or :

axios.post("http://localhost:yourport/send-email", {
    to: "test@gmail.com",
    subject: "Hello from sigma boy",
    html: "<p>Test</p>"
})

✨ Suggestion

Recommended to verify your Redis Database is configured with the noeviction policy.

Why? :

If Redis runs out of memory and eviction is turned on (like volatile-lru or allkeys-lru), it might start delete keys. This can cause your queued jobs to disappear without warning.

About

πŸ“©πŸ•’ Email Queue system using BullMQ & Nodemailer

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors