[Solved] Main Virtual domain with Google MX and Postfix not working

7 posts / 0 new
Last post
#1 Wed, 10/02/2013 - 05:22

[Solved] Main Virtual domain with Google MX and Postfix not working

This is a bit complicated, I'll try to explain.

The setup:

  1. CentOS 6 server, with FQDN - let's say "maindomain.com"
  2. Webmin 1.650, Virtualmin 1.0 installed and running
  3. Postfix 2.6.6 running and configured as best as I could find online help (biggest PITA of my life) - mailx is able to send emails
  4. "maindomain.com" added as virtual domain in Virtualmin (for ease of use), along other domains
  5. "maindomain.com" has MX records pointing to Google (mail hosted on Google Apps), and receiving mail from outside

The problem:

PHP mail() function (from WordPress and Tectite FormMail for example) is not able to send emails to any address at @maindomain.com (any.user@maindomain.com for example) - seems to ignore the MX records.

I receive error emails on the root mailbox (can open with mutt) like this:

From: Mail Delivery System <MAILER-DAEMON@maindomain.com>
To: apache@maindomain.com
Subject: Undelivered Mail Returned to Sender
This is the mail system at host mail.maindomain.com.
I'm sorry to have to inform you that your message could not
be delivered to one or more recipients. It's attached below.
<any.user@maindomain.com>: unknown user: "any.user"
Reporting-MTA: dns; mail.maindomain.com
... (the rest of the email)

And this is an example error in /var/log/maillog

Sep 27 16:42:20 maindomain postfix/pickup[27879]: 20F892A4012C: uid=48 from=<apache>
Sep 27 16:42:20 maindomain postfix/cleanup[28139]: 20F892A4012C: message-id=<97c9961b4436e5351e10b1ebd40da79b@virtualdomain.com>
Sep 27 16:42:20 maindomain postfix/qmgr[1640]: 20F892A4012C: from=<apache@maindomain.com>, size=891, nrcpt=1 (queue active)
Sep 27 16:42:20 maindomain postfix/local[28141]: 20F892A4012C: to=<any.user@maindomain.com>, relay=local, delay=0.3, delays=0.03/0.16/0/0.11, dsn=5.1.1, status=bounced (unknown user: "any.user")
Sep 27 16:42:20 maindomain postfix/cleanup[28139]: 649B22A4012E: message-id=<20130927134220.649B22A4012E@mail.maindomain.com>
Sep 27 16:42:20 maindomain postfix/bounce[28142]: 20F892A4012C: sender non-delivery notification: 649B22A4012E
Sep 27 16:42:20 maindomain postfix/qmgr[1640]: 649B22A4012E: from=<>, size=2780, nrcpt=1 (queue active)
Sep 27 16:42:20 maindomain postfix/qmgr[1640]: 20F892A4012C: removed
Sep 27 16:42:20 maindomain postfix/local[28141]: 649B22A4012E: to=<root@maindomain.com>, orig_to=<apache@maindomain.com>, relay=local, delay=0.07, delays=0/0/0/0.07, dsn=2.0.0, status=sent (delivered to mailbox)
Sep 27 16:42:20 maindomain postfix/qmgr[1640]: 649B22A4012E: removed

I have attached a few excerpts from postfix setup, if you need anything else, please ask:


myhostname = mail.maindomain.com
mydomain = maindomain.com
myorigin = $mydomain
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain

local_recipient_maps = unix:passwd.byname $alias_maps

mynetworks_style = host

relay_domains = $mydestination

virtual_alias_maps = hash:/etc/postfix/virtual
virtual_maps = hash:/etc/postfix/virtual

relayhost = $mydomain

smtpd_tls_cert_file = /etc/postfix/postfix.cert.pem
smtpd_tls_key_file = /etc/postfix/postfix.key.pem
smtpd_tls_security_level = may
smtpd_tls_mandatory_protocols = SSLv3, TLSv1
smtpd_tls_mandatory_ciphers = high


virtualdomain1.com bla
virtualdomain2.com bla

I know it has to have something to do with relay settings and virtual aliases, but I couldn't find any documentation related to this particular setup for Postfix.

Wed, 10/02/2013 - 05:29

in the edit server setting of virtualmin, under enabled features is "mail for domain" checked if it is uncheck it and try again?

Wed, 10/02/2013 - 06:24 (Reply to #2)

I checked and applied it, now I get this in maillog (and no return error in root mailbox):

... status=bounced (User unknown in virtual alias table)

I see that Virtualmin updated /etc/postfix/virtual with the domain name, and I had to edit main.cf like this:

mydestination = localhost.$mydomain, localhost

because I was getting this warning when restarting postfix:

...warning: do not list domain maindomain.com in BOTH mydestination and virtual_alias_domains
Wed, 10/02/2013 - 06:20

It's recommended to use an actual FQDN, like "host.domain.tld", for the server, and NOT put "domain.tld" under Virtualmin control. You can manage the zone through Webmin's BIND module though, if required.

Wed, 10/02/2013 - 06:28 (Reply to #4)

The DNS for my VPS is handled by a dedicated app from the company that rented me my server. I don't think I can use Bind in this case, or can I?

Wed, 10/02/2013 - 07:01 (Reply to #5)

You don't really need to use BIND for that, nope. You'd just want to make sure to use a name like "server.domain.tld" for the server, and not put "domain.tld" under Virtualmin control. While not strictly necessary to do that, it helps keep things clean and prevent followup problems. :)

Fri, 10/04/2013 - 07:20 (Reply to #6)

Wow! It works now! Thank you!

I removed the main domain from Virtualmin and added it manually in httpd.conf (same settings, copied from Virtualmin's), and it just works - I don't know why, maybe it was writing something wrong in Postfix's config.

Topic locked