This is a bit complicated, I’ll try to explain.
The setup:
- CentOS 6 server, with FQDN - let’s say “maindomain.com”
- Webmin 1.650, Virtualmin 1.0 installed and running
- 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
- “maindomain.com” added as virtual domain in Virtualmin (for ease of use), along other domains
- “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=
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=, size=891, nrcpt=1 (queue active)
Sep 27 16:42:20 maindomain postfix/local[28141]: 20F892A4012C: to=, 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=, orig_to=, 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:
/etc/postfix/main.cf
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
/etc/postfix/virtual
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.