Friday, June 20, 2008

Tell postfix not to send email to local

We want to config the server can only send emails, can NOT receive emails from local or remote. Because our domain is pointed to this server, But our email server is on Google Enterprise. So before If we want to send email from the server, It first looks up locally, and send to local directly, So emails never get reach to Google.

I tried: http://www.postfix.org/faq.html#null_client But I seems not work.

After check out the postfix log:

Jun 20 08:45:15 example.com postfix/pickup[21505]: [ID 197553 mail.info] 9EE3D43D17: uid=0 from=<root>
Jun 20 08:45:15 example.com postfix/cleanup[21511]: [ID 197553 mail.info] 9EE3D43D17: message-id=<20080620084515.9EE3D43D17@example.com>
Jun 20 08:45:15 example.com postfix/qmgr[21506]: [ID 197553 mail.info] 9EE3D43D17: from=<root@example.com>, size=294, nrcpt=1 (queue active)
Jun 20 08:45:15 example.com postfix/error[21509]: [ID 197553 mail.info] 9EE3D43D17: to=<theplant@example.com>, relay=none, delay=0, status=bounced (User unknown in virtual alias table)
Jun 20 08:45:15 example.com postfix/cleanup[21511]: [ID 197553 mail.info] 9FC7E43D19: message-id=<20080620084515.9FC7E43D19@example.com>
Jun 20 08:45:15 example.com postfix/qmgr[21506]: [ID 197553 mail.info] 9FC7E43D19: from=<>, size=1973, nrcpt=1 (queue active)
Jun 20 08:45:15 example.com postfix/error[21509]: [ID 197553 mail.info] 9FC7E43D19: to=<root@example.com>, relay=none, delay=0, status=bounced (User unknown in virtual alias table)
Jun 20 08:45:15 example.com postfix/qmgr[21506]: [ID 197553 mail.info] 9FC7E43D19: removed
Jun 20 08:45:15 example.com postfix/qmgr[21506]: [ID 197553 mail.info] 9EE3D43D17: removed

Even you set

 local_transport = error:local delivery is disabled

But when you have aliasmaps, aliasdatabase, virtualaliasmaps. Postfix will still try to find the alias name in local. So it fails when it can not find it.

main.cf

myorigin = example.com
#relayhost = example.com
inet_interfaces = 127.0.0.1
#local_transport = error:local delivery is disabled
## -- Maps
#alias_maps = dbm:/opt/csw/etc/postfix/aliases
#alias_database = dbm:/opt/csw/etc/postfix/aliases
canonical_maps = dbm:/opt/csw/etc/postfix/canonical
recipient_canonical_maps = dbm:/opt/csw/etc/postfix/recipient_canonical
sender_canonical_maps = dbm:/opt/csw/etc/postfix/sender_canonical
#virtual_alias_maps = dbm:/opt/csw/etc/postfix/virtual

master.cf

discard   unix  -       -       n       -       -       discard
#local     unix  -       n       n       -       -       local
virtual   unix  -       n       n       -       -       virtual
And Another thing, make sure your hostname is NOT your domain. because It will check hostname first and mx record? I guess.