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 have a Postfix mail server set up. I have one account credentials entered in. The mail server is sending mail through the Google Apps mail servers. So in a postfix config file I have my gmail credentials as:

test@mydomain.com
mypassword

In my PHP application I use the mail() function to send mail.

Everything works, except no matter what I set the 'from' header address to, it ALWAYS says it is coming from test@mydomain.com.

I have used other setups where the email's 'from' header could be altered, so that I could have support@mydomain.com, noreply@mydomain.com, etc..

Any help would be greatly appreciated in how to set this up.

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

You can't change that at the Postfix level. Postfix already does what you want. Google replaces the sender with the authorized account. This is a "feature" of Google Apps to disallow the forging of senders.

Edit: If you don't change Google Apps, then you have to change Postfix' behavior.

In main.cf edit or add:

sender_dependent_relayhost_maps = hash:/etc/postfix/sender_relayhost
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/smtp_relayhost_auth
smtp_sasl_security_options = noanonymous
smtp_sender_dependent_authentication = yes

in /etc/postfix/sender_relayhost put:

user1@mydomain.com          [aspmx.l.google.com]
user2@mydomain.com          [aspmx.l.google.com]

in /etc/postfix/smtp_relayhost_auth put

user1@mydomain.com      user1@mydomain.com:mypassword
user2@mydomain.com      user2@mydomain.com:hispassword

and so on.

share|improve this answer
    
Are you familiar with a way in Google Apps to change this? If not, how can I add more authorized accounts in Postfix? I only know how to set one account. –  donutdan4114 Oct 30 '11 at 20:20
    
@donutdan4114 It is somewhere in the Google Apps help. Found it two weeks ago but lost the link. –  mailq Oct 30 '11 at 20:28
    
@donutdan4114 Researched: mail.google.com/support/bin/answer.py?answer=22370 –  mailq Oct 30 '11 at 20:30
    
Will check out when I have power again, and see if this does what I need –  donutdan4114 Nov 1 '11 at 0:25
    
Thank you! I got it working with your solution. –  donutdan4114 Nov 3 '11 at 22:14
add comment

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.