Hi everyone! I started this project because I needed an smtp able to manage the timing of email delivery, with full control over the whole procedure.
I started from the nodemailer-amqp-example project, which is an example of how to handle a queue with the RabbitMQ broker and NodeJs.
I turned the publisher.js process into an SMTP server, and replaced the server.js process with an ad hoc Postfix. I also had to rewrite one of the dependencies because of some charset conversion issues, project here: mailparser-iconv-full .
So, what is it for?
It's for when you need to send a large amount of email, usually newsletters, and hand off to an external system the job of spreading the sending out over time.
What can you use it with?
With any SMTP client
Below are the link to the github project and the installation guide 🙂
The most important parameter is in config.json, delaysend, which defines how many milliseconds pass between one email and the next.
Install it as an internet site, and enter a valid FQDN
After that, go to the file
bash
/etc/postfix/master.cf
and change the listening port
from the line
text
smtpd inet n - y - - smtpd
to the line
text
9267 inet n - y - - smtpd
this way we'll have port 9267 listening on localhost
Installation
Clone the git project with git clone and move into the folder
bash
cd node-mailing-amqp
Install the required dependencies
bash
npminstall--production
Create the log folders
bash
./setup.sh
Make sure the RabbitMQ server is running, and also check that the configuration in config.json is correct.
Running
This project is made of three parts:
Postfix SMTP server . This is the actual service that will ultimately send the emails, it runs on localhost (port 9267) and only accepts mail from localhost.
Subscriber process (subscriber.js). This is the process that fetches messages from the rabbit queue and sends them out through postfix. Each fetch is timed by the config.delaysend value in the config.json file
Publisher process (publisher.js). This is the bridge smtp that validates the user sending the email, and puts the email to be delivered into the rabbit queue
You can start all the processes with the command (inside the folder)
bash
./restart.sh
Setting up credentials
Edit the auth.json file and add the accounts that the system will use