Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

share|improve this question
    
Can you post your current config? This way we can help you better. –  Khaled Jan 13 '12 at 17:16
    
Added a link, thanks! –  Ben Scobie Jan 13 '12 at 17:28
    
    
Just switch the right hand side of the transport file as described in the duplicate question. –  mailq Jan 14 '12 at 0: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 Answers 3

up vote 1 down vote accepted

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.

share|improve this answer

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

share|improve this answer
    
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

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
share|improve this answer
    
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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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