Question : Change Sender Name in Postfix?

Hello,

We run a LAMP server running CentOS 5, Postfix 2.3.3, and PHP5.x   When our PHP scripts send out email with the PHP mail() function, users's receive the emails with a Sender of "Apache" in the From area of the email.

We would like to be able to change "Apache" to something else, and have the change be global so that all of our PHP scripts that use the mail() function (there are many of them) will have this same new Sender name.

Thank you in advance.

Karl Cox

Answer : Change Sender Name in Postfix?


Hello,
check out your php.ini file, in the section [mail function]. You probably have something like the following defined:

sendmail_path = /usr/sbin/sendmail -t -i

and pretty much all else commented out. So what happens is php's mail() function calls the sendmail binary (which is the mail injection command of postfix) and gives it the message. Because postfix doesn't trust local users, it discards the 'from' field and replaces it with the Linux userid of the calling process. In this case, it is 'Apache'.

What you need to do is make it use SMTP instead of the sendmail command. You will need to know the name of your SMTP server, which may be 'localhost' if your postfix is running as such. In the php.ini's [mail function] section, add:

SMTP =
smtp_port = 25
sendmail_from = [email protected]


The first two options will make PHP talk to the SMTP server directly, which implicitely trusts the information given to it; the last option sets the default sender email address to use.

Hope this helps,
Christophe
Random Solutions  
 
programming4us programming4us