I setup Postfix a few days ago to deliver email bound for my host name remotely instead of locally as I want email sent to my remote admin@hostname.com account without trying to be sent locally. However, this causes a problem as it tries to send local bound mail(root) to my remote server as well (root@hostname.com).

I would like E-mail bound for admin@myhostname.com to be sent to the remote server(GMail Apps in this case) and everything else sent locally(using the alias file perhaps), is this possible?

My current configuration: http://pastebin.com/htwSQB61


Okay I finally managed to solve this and it was quite simple really:


mydestination = localhost.$mydomain, localhost
virtual_alias_maps = hash:/etc/postfix/virtual


root root@localhost

As all local accounts usually get aliased to root this solution works pretty well as instead of trying to send all the mail remotely it will send it locally. If you have an account called admin or something else you don't want going locally just make sure it's not aliased to root.


I may be misunderstanding the question, but the following line in /etc/aliases will cause all may sent to the admin user to be forwarded to the specified address (run newaliases after editing).

admin: me@gmail.com
  • I've tried this however I always get the following error: to=<admin@thedomain.com>, orig_to=<admin>, relay=local, delay=1.1, delays=0.23/0.05/0/0.84, dsn=5.1.1,status=bounced (unknown user: "admin") – Ben Scobie Jun 20 '12 at 18:24
  • @BenScobie Did you run newaliases and then service postfix reload after editing the file? – mgorven Jun 20 '12 at 18:29
  • Okay I made an "admin" account and now the e-mail is sent, but it is still going locally, probably because of the $myhostname in mydestination. I need to somehow get it to ignore that when doing an alias lookup. – Ben Scobie Jun 20 '12 at 21:51
  • Check in main.cf if /etc/aliases is used. Something like alias_maps = hash:/etc/aliases – Laurentiu Roescu Sep 11 '12 at 13:41
  • you need to add this line in /etc/postfix/aliases according to your main.cf. – Laurentiu Roescu Sep 11 '12 at 13:44

Try this: http://www.cyberciti.biz/tips/howto-postfix-masquerade-change-email-mail-address.html I have used this solution before and it worked.

  • I'm not 100% sure that this will solve my problem, it seems to solve something completely different. – Ben Scobie Jan 13 '12 at 19:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.