Haraka is an open source SMTP server written in Node.js which provides extremely high performance coupled with a flexible plugin system allowing Javascript programmers full access to change the behaviour of the server.
In Web hosting industry dominated by Cpanel, Haraka can co-exist with Exim and can be used as an alternative mail server for clients with large mailing lists. Haraka consumes negligible memory thereby easing the job off Exim which can cater to normal clients hosted on a cPanel server.

Here we guide to configure Haraka as outgoing mail server only. If you want to accept emails and deliver it locally, please refer the official docs.

1. Install Node.js binary (http://nodejs.org/download/)

# cd /usr/local/src/
# wget http://nodejs.org/dist/v0.10.28/node-v0.10.28-linux-x64.tar.gz
# tar zxvf node-v0.10.28-linux-x64.tar.gz
# mv node-v0.10.28-linux-x64 /usr/local/node
# chown -R root:root /usr/local/node
# ln -s /usr/local/node/bin/node /usr/local/bin/
# ln -s /usr/local/node/bin/npm /usr/local/bin/

2. Install git and Haraka

# yum install git -y
# cd /usr/local/
# git clone https://github.com/baudehlo/Haraka.git
# mv Haraka haraka
# cd haraka
# npm install

3. Create symlinks once the installation is complete

# ln -s /usr/local/haraka/bin/haraka /usr/local/bin/

4. Also copy over the start-up script

# cp /usr/local/haraka/contrib/haraka.init /etc/init.d/haraka
# chmod 755 /etc/init.d/haraka

5. Initialize Haraka config directory

# haraka -i /etc/haraka/

6. make changes to config files

vi /etc/haraka/config/smtp.ini:

; address to listen on (default: all IPv6 and IPv4 addresses, port 25)
; use “[::0]:25” to listen on IPv6 and IPv4 (not all OSes)

; Note you can listen on multiple IPs/ports using commas:

; public IP address (default: none)
; If your machine is behind a NAT, some plugins (SPF, GeoIP) gain features
; if they know the servers public IP. If ‘stun’ is installed, Haraka will
; try to figure it out. If that doesn’t work, set it here.

; Time in seconds to let sockets be idle with no activity

; Drop privileges to this user/group

; Don’t stop Haraka if plugins fail to compile

; Run using cluster to fork multiple backend processes

; Daemonize

; Spooling
; Save memory by spooling large messages to disk
; Specify -1 to never spool to disk
; Specify 0 to always spool to disk
; Otherwise specify a size in bytes, once reached the
; message will be spooled to disk to save memory.

vi /etc/haraka/config/plugins:

# default list of plugins

# Log to syslog (disabled by default, see docs)
# log.syslog

# control which IPs, rDNS hostnames, HELO hostnames, MAIL FROM addresses, and
# RCPT TO address you accept mail from. See ‘haraka -h access’.

# block mails from known bad hosts (see config/dnsbl.zones for the DNS zones queried)

# Check mail headers are valid

# block mail from some known bad HELOs – see config/helo.checks.ini for configuration

# see ‘haraka -h tls’ for config instructions before enabling!
# tls

# Only accept mail where the MAIL FROM domain is resolvable to an MX record

# Disconnect client if they spew bad SMTP commands at us

# Only accept mail for your personal list of hosts. Edit config/host_list
# NOTE: THIS IS REQUIRED for inbound email.

# Queue mail via smtp – see config/smtp_forward.ini for where your mail goes


vi /etc/haraka/config/auth_flat_file.ini:



vi /etc/sysconfig/haraka:


7. Fix permissions:

# chown -R mail:mail /etc/haraka/

8. Configure chkconfig:

# chkconfig –add haraka
# chkconfig haraka on

9. And finally.., start Haraka

# service haraka start

In case haraka failed to start for any reason, check its log file at /var/log/haraka.log.

[root@localhost ~]# service haraka start
Starting haraka: /usr/bin/env: node: No such file or directory

If you encounter the following error while starting Haraka:

.. then edit /usr/local/haraka/bin/haraka, and modify its first line to:

#!/usr/bin/env /usr/local/bin/node

.. and Haraka will start fine:

[root@localhost ~]# service haraka start
Starting haraka: [ OK ]

Now that Haraka is up and running, use the following settings to send email:

SMTP Server:
Port: 587
SMTP Username: emailuser
SMTP Password: password

On a cPanel server, run Haraka on another port and use it as outgoing email server for bulk mailing/newsletter tasks and spare Exim from the pain!

Leave a Reply

Your email address will not be published. Required fields are marked *