0

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

Ben Scobie
  • 11
  • 5
  • Can you post your current config? This way we can help you better. – Khaled Jan 13 '12 at 17:16
  • possible duplicate of [postfix: deliver mail to specific emai addresses locally and send the rest to relayhost](http://serverfault.com/questions/150946/postfix-deliver-mail-to-specific-emai-addresses-locally-and-send-the-rest-to-re) – mailq Jan 14 '12 at 00:49
  • Just switch the right hand side of the transport file as described in the duplicate question. – mailq Jan 14 '12 at 00:51
  • I don't understand what I'd put in "my.mailserver", I'm using Google Apps? – Ben Scobie Jan 14 '12 at 14:14

3 Answers3

1

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

main.cf:

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

/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.

Ben Scobie
  • 11
  • 5
0

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
mgorven
  • 30,615
  • 7
  • 79
  • 122
  • I've tried this however I always get the following error: to=, orig_to=, 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
-1

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