Most of our projects require some sort of email functionality, whether it's a community site, an enterprise site or an application of any sort. We often find ourselves at a point where either we have to pay someone to let us send emails reliably or struggle to setup our own SMTP server.
Setting up an SMTP server requires specialised skills, hours of messing around with the configuration, and then managing the server. So most of us just pay someone to let us send emails. Nothing bad with that, I have done it for many of my projects - Until I discovered Haraka!
Let's see how we can setup Haraka in 10 minutes and test it for another 5. So thats 15 minutes in total from the project inception to delivery.
Ohh, so we got 5 spare minutes to quickly get a cup of coffee and may be (just may be) do our usual engineering dance.
Alright, enough messing around. Let's do this.
Install Haraka globally
We are installing Haraka globally because once installed we would like to run it as root however you can bind the process to any other user. Note that on all (if not most) operating systems port 25 which is a default port for SMTP is reserved for root or the user with privelleged access
you might have to either switch to the root user or sudo to install
Or, use nvm (Node Version Manager) to install instead of npm. This might make life little easier if you are on OSX since it will install Haraka 'globally' for that user.
npm install -g Haraka
Once installed, we will create a new Haraka instance which will setup basic configuration for us to mess around later.
Create a directory where a new instance will keep its config and execute haraka using -i option in that directory which will create all necesary config and structure for you
haraka -i haraka_test
We are ready to start our SMTP server now. Yes you can configure it to your likings and yes a production instance will need more configuration and possibly a plugin or two. You can get more info from Haraka documentation or tweet me and I will try to help you out. See
haraka_test/config/plugins for configuration options. You should change the user/group config in smtp.ini before starting.
sudo haraka -c haraka_test
Thats it, you have a brand new SMTP server running.
Time to Test
Locally you can test by using a nice little script called Swaks. I would recommend to download a package which has a script you can execute to test your new SMTP server. Once downloaded, test your local Haraka SMTP server.
swaks -s localhost -t firstname.lastname@example.org -f email@example.com
You should see something like this. I wanted to show you this error first so we can look at Haraka host config to update and fix.
Add a line for any domain or a line per domain for which you want to accept emails. In my test I have just added a single domain
Restart Haraka. You can do so by simply terminating the process and starting it again. You should run Haraka as a service for production.
Voila, we got a very chatty email server.
What would you create with Haraka?
Here are some ideas which you can pursue to either solve your own problem or be creative and solve a wider issue.
- Your company's SMTP server to send and receive emails
- Start a SMTP email relay service like sendgrid, mailgun etc. But better?
- May be a new web email? you will also need a good client software and a email storage and forwarding for that
- How about a temporary or disposable email service like a 10minutemail
- Or just about anything which involves email. If you are creating something which does not involve email, then Haraka is probably not the best choice for you (you already knew that)