Published in


Node.js dummy email queue, when SMTP fails.

There are many npm packages that solves the following issue.

/--X--| SMTP 1 |
/ ^ |--------|
/ \--- Retry with next provider
|----------------|/ |--------| |------------------|
| Mail | ---X--> | SMTP 2 | /->| ^_^ Happy user |
|----------------|\ ^ |--------| / |------------------|
\ \--- Retry /
\ |--------| /
\---->| SMTP 3 |--/

The following diagram is taken from Meteor-Mailer which is based on nodemailer which im going to use in the example below.

Code below is responsible for the following
1. Try to send email with default email (here it would be Meteor.JS email system)
2. If it fails, it starts email queue
3. It tries to send email with first email provider. If this fails it tries again with another.
4. If all fails, error callback is called.

Not that this script is dummy, in real scenarios real queue should be used, for instance one that is saved in Mongo.




Stories from creative software house based in Poland, with a love for all web technology

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Mateusz Wojczal

Mateusz Wojczal

founder of Qunabu Interactive from Gdańsk, Poland. Full-stack web developer with over a dozen years of experience.

More from Medium

How to find Node.js Developers in India?

Node.js vs. React.js Comparison: Which to Choose for your JavaScript App Development?

TaskBlaster: A Simple Full Stack CRUD App Using Sinatra, React, and MaterialUI

How to use fetch in NodeJS

Image saying { FETCH API }