0

I'm trying to figure out catchall forwarding for multiple domains on my Ubuntu server. I have it working for a single domain (maindomain) but cannot get the addons 1 and 2 to work.

My /etc/postfix/virtual looks like

@example.com onename@gmail.com
@example.net twoname@gmail.com
@example.org twoname@gmail.com

and /etc/postfix/main.cf looks like:

virtual_alias_domains = example.com, example.net, example.org
virtual_alias_maps = hash:/etc/postfix/virtual
alias_database = hash:/etc/aliases
...
mydestination = server.example.com, server, localhost.localdomain, localhost
...
mydomain = example.com

Originally I had example.com in the mydestination list, which worked, but I moved it while trying to add the addondomains because of this postfix documentation.

What do I need to add and where? I have yet to do anything with the alias_database. The mail system will only be used for catch-all domain forwarding, but I want it to be able to handle multi domains to different addresses.

EDIT:

username@server:~$ ls -ltr /etc/postfix/virtual*
-rw-r--r-- 1 root root   122 Jan 16 09:48 /etc/postfix/virtual
-rw-r--r-- 1 root root 12288 Jan 16 10:10 /etc/postfix/virtual.db

EDIT: Running the logs gives:

Jan 18 14:56:22 server postfix/smtpd[27433]: warning: dict_nis_init: NIS domain name not set - NIS lookups disabled
Jan 18 14:56:32 server postfix/smtpd[27433]: connect from mail-wm0-f44.google.com[74.125.82.44]
Jan 18 14:56:32 server postfix/smtpd[27433]: 8ADF517FA6E: client=mail-wm0-f44.google.com[74.125.82.44]
Jan 18 14:56:32 server postfix/cleanup[27437]: 8ADF517FA6E: message-id=<CAOJdi7gjX9_Qm7exDjOrBVTtXF5hhysWcRqUp4pYx4NuwwsxWA@mail.gmail.com>
Jan 18 14:56:32 server postfix/qmgr[11433]: 8ADF517FA6E: from=<twoname@gmail.com>, size=2493, nrcpt=1 (queue active)
Jan 18 14:56:32 server postfix/smtpd[27433]: disconnect from mail-wm0-f44.google.com[74.125.82.44]
Jan 18 14:57:27 server postfix/smtp[27438]: connect to gmail-smtp-in.l.google.com[2a00:1450:400c:c08::1a]:25: Network is unreachable
Jan 18 14:57:28 server postfix/smtp[27438]: 8ADF517FA6E: to=<twoname@gmail.com>, orig_to=<test@example.net>, relay=gmail-smtp-in.l.google.com[74.125.140.26]:25, delay=55, delays=0.06/0.01/55/0.08, dsn=2.0.0, status=sent (250 2.0.0 OK 1453128888 k126si25800198wma.23 - gsmtp)
Jan 18 14:57:28 server postfix/qmgr[11433]: 8ADF517FA6E: removed
Frederik
  • 3,359
  • 3
  • 32
  • 46
Byte Insight
  • 123
  • 7

2 Answers2

1

I could be wrong on this, but please execute ls -ltr /etc/postfix/virtual*

If virtual.db is listed before virtual, then you need to execute postmap /etc/postfix/virtual. You need to do that every time you change the file.

Law29
  • 3,557
  • 1
  • 16
  • 28
  • Hi Law, thanks for the response. I have done what you suggested `username@server:~$ ls -ltr /etc/postfix/virtual* -rw-r--r-- 1 root root 122 Jan 16 09:48 /etc/postfix/virtual -rw-r--r-- 1 root root 12288 Jan 16 10:10 /etc/postfix/virtual.db` But I ran your command anyway. I believe I had run it previously anyway before I restarted postfix but it never harms to run it again. – Byte Insight Jan 17 '16 at 19:23
  • OK so that wasn't it (I also see that postmap was mentioned in the link you quoted). Unfortunately along with the postfix restart that's the easy things. The rest looks good. The http://www.postfix.org/postconf.5.html#virtual_alias_domains example says comma or space, so that shouldn't explain why the first one works and not the others. So... logs? – Law29 Jan 17 '16 at 22:35
  • I have checked the mx records and added a logs edit above. No idea really myself. I checked the spam bin! Thanks for your help last night. – Byte Insight Jan 18 '16 at 15:17
  • According to your logs, it's working. Mail 8ADF517FA6E sent to test@addondomain1.net is being successfully resent to twoname@gmail.com. What gmail does with it is another problem! Gmail can see that it is a mail sent from the same account, that the mail is invalid according to SPF and DKIM because it says it's coming from gmail when in fact it's coming from your server... there are lots of problems with mail forwarding, but postfix is working. – Law29 Jan 18 '16 at 15:50
  • Thanks Law. I wonder how cpanel' catch all forwarding works then? – Byte Insight Jan 18 '16 at 17:36
  • Ok, I'm going to look at http://www.binarytides.com/postfix-mail-forwarding-debian/ when I get home and will report back. – Byte Insight Jan 18 '16 at 18:17
  • I really need to thank you for helping because I have finally solved the problem! Thanks Law - all the best. – Byte Insight Jan 18 '16 at 20:21
  • @davies-barnard Well thanks would be upvoting my analysis, I don't have so much "rep" that I won't see the difference :) -- Lawrence – Law29 Jan 18 '16 at 22:36
  • Just tried but I don't have enough to rep to change the publicly seen rep. Sorry. – Byte Insight Jan 18 '16 at 22:37
  • Let us [continue this discussion in chat](http://chat.stackexchange.com/rooms/34504/discussion-between-law29-and-davies-barnard). – Law29 Jan 18 '16 at 22:39
  • After hours of Googling trying to get catchall mail forwarding to work for multiple domains, this was the solution for me. Thank you. – Leo Galleguillos Jul 02 '18 at 08:01
1

Ok.

So this is actually really very simple.

As one of the comments on this link http://www.binarytides.com/postfix-mail-forwarding-debian/ points out. Gmail will not let you send an email to itself via a forwarded domain so.

me@gmail.com sending to test@mydomain.com which is forwarded to me@gmail.com will not work. despite me@gmail.com to me@gmail.com working!

Wow.

Byte Insight
  • 123
  • 7