How can I configure a Haraka mail server to forward mails to another address on another domain?

What you need to do is first setup aliasing that address. You can do this with the aliases plugin (or the plugin you listed in your question). See the documentation here: http://haraka.github.io/manual/plugins/aliases.html (and add the plugin to config/plugins).

Secondly you need to set things up to relay everything outbound, since you want everything to go to this one address. You can do this with the relay plugin by setting the all=true option: http://haraka.github.io/manual/plugins/relay.html - but note how it says not to use that in production, so read the next section carefully:

Finally you need to make sure you don't relay mail that isn't for the known recipients. You do this with the access plugin. Just blacklist every email address, and whitelist the ones you want to allow. http://haraka.github.io/manual/plugins/access.html

Be careful with this setup. You can all too easily setup an open relay. If you get stuck, you can get real-time help on the #haraka IRC channel on Freenode, or use the Haraka mailing list.


I had the same problem, and I solved it by installing haraka-alias-forward plugin:

https://github.com/chadsmith/haraka-alias-forward/blob/master/config/rcpt_to.alias_forward

If you have Haraka installed already then:

  • copy the rcpt_to.alias_forward.js file to the plugins folder
  • copy the rcpt_to.alias_forward file to the config folder

If you start with Haraka from scratch, then:

git clone https://github.com/haraka/Haraka.git
cd Haraka
git clone https://github.com/chadsmith/haraka-alias-forward
haraka -i <where you want to install Haraka>

Enable the plugin in the config/plugins file:

# RCPT TO
# At least one rcpt_to plugin is REQUIRED for inbound email. The simplest
# plugin is in_host_list, see 'haraka -h rcpt_to.in_host_list' to configure.
#rcpt_to.in_host_list
#rcpt_to.qmail_deliverable
#rcpt_to.ldap
#rcpt_to.routes
rcpt_to.alias_forward

Don't forget to update the rcpt_to.alias_forward config file with your rules.

{
  "example.com": {
    "[email protected]": ["[email protected]"]
  }
}

If you want all emails sent to your domain to be forwarded to your Gmail account, use this config:

{
  "example.com": {
    "*": ["[email protected]"]
  }
}

Oh, one more thing. If you use the latest version of Haraka, you'll get an error when Haraka starts if haraka-alias-forward plugin is enabled. Change rcpt_to.alias_forward.js file as follows:

from:

Address = require('./address').Address

to:

Address = require('address-rfc2821').Address;

You'll need to restart Haraka for these changes to take effect. This worked for me. Good luck!