6

I'd like to setup an Haraka mail server on a domain (let's say 'example.com') that will only act as a forwarding service to a 'gmail.com' email address. For the sake of the example let's say I'd like all emails sent to 'me@example.com' to be forwarded to 'me@gmail.com'.

I've already partially succeeded in setting this up using the 'rcpt_to.alias_forward' plugin. Sending the mail using the server itself works, but sending it from gmail still doesn't work. The logs indicate that the message is forwarded in successfully, but it never arrives at the forwarding address.

masegaloeh
  • 18,236
  • 10
  • 57
  • 106
juriejan
  • 161
  • 1
  • 2
  • 1
    *sending it from gmail still doesn't work. The logs indicate that the message is forwarded in successfully, but it never arrives at the forwarding address.* The first statement is about sending mails from gmail, the second one about receiving mails to be forwarded. Could you please clarify your setup and include examples, configuration and logs. – sebix Feb 19 '15 at 08:52

2 Answers2

6

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/plugins/aliases (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/plugins/relay - 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/plugins/access

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.

fourk
  • 103
  • 3
Matt Sergeant
  • 514
  • 2
  • 5
  • That's a poor answer that does not explain anything. First, the aliases plugin should be one of the first listed. Then, it's not a good idea to run a relay node (as you said). Finally the access plugin documentation is so poor, an example would have been useful. IIUC, access's domain/mails are those that gets in, not the opposite. In the end, this answer does not help at all. – xryl669 Jan 21 '19 at 16:22
3

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": {
    "me@example.com": ["me@gmail.com"]
  }
}

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

{
  "example.com": {
    "*": ["me@gmail.com"]
  }
}

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!

claudius
  • 31
  • 2