whit3fir3 Posted August 19, 2010 Share Posted August 19, 2010 I am having an issue sending messages out from a PHP function and I can not figure it out. I have a development server running Fedora 13 with Postfix for my MTA. I configured postfix and when I send a message and set the FROM headers the email messages appears to come from that person. On my production server I am running CentOS 5.5 with sendmail. It is the same PHP code as I have in my dev environment (that works) so I feel confident in ruling that. Now when the system sends out a message it comes from Apache@mydomain.com. Previously before monkeying with Sendmail some all messages were coming from Apache@localhost.localdomain. Now I have a couple of things I can do as quick fixes for this, but neither are a real long term solution. I can setup user masquerading in sendmail and have the messages that are submitting from Apache appear to come from another user at mydomain.com. The other idea I have thought of is in the /etc/php.ini I in the command for sendmail there I could statically set the FROM address in the php.ini. The problem with both of these option is if I want to send an email message from another user in the future I can't. What I want to know is if anyone knows what needs to be sent (in sendmail I am assuming) to allow PHP to set the FROM address in an email message so that my email messages to do appear to come from Apache@mydomain.com? Thanks, whit3fir3 Quote Link to comment https://forums.phpfreaks.com/topic/211143-php-mail-problem/ Share on other sites More sharing options...
PFMaBiSmAd Posted August 19, 2010 Share Posted August 19, 2010 The From: address you use needs to be a valid mail box hosted at your sending mail server. Any user entered email address should be put in as the Reply-to: address. Quote Link to comment https://forums.phpfreaks.com/topic/211143-php-mail-problem/#findComment-1101103 Share on other sites More sharing options...
whit3fir3 Posted August 19, 2010 Author Share Posted August 19, 2010 PFMaBiSmAd, Thank you for your quick reply and I am going to try your suggestion, but I do not think that is the solution. In fact I know in my dev environment (running postfix) I can sent the From and Reply-To address using PHP to be anything I want it to be. I guess I just do not understand why I would need a valid mailbox on the system. These are all OUTGOING messages only. The MX records for the domain point to another server, but the server in question in included in the domains SPF record (no that the SPF record has any bearing on my problem). Thanks, whit3fir3 Quote Link to comment https://forums.phpfreaks.com/topic/211143-php-mail-problem/#findComment-1101106 Share on other sites More sharing options...
cliffdodger Posted August 25, 2010 Share Posted August 25, 2010 Perhaps you could post some of the code in question? I know I had a case where my from headers were getting overwritten because I was doing something out of order. check your code against examples from these sites: http://email.about.com/od/emailprogrammingtips/qt/How_to_Send_Emails_with_Extra_Headers_in_PHP.htm - $headers = "From: sender@example.com\r\n" . "X-Mailer: php"; http://php.net/manual/en/function.mail.php The From: address you use needs to be a valid mail box hosted at your sending mail server. - this wasn't the case the last time I wrote a script that sent emails. Maybe under specific circumstances. Quote Link to comment https://forums.phpfreaks.com/topic/211143-php-mail-problem/#findComment-1103736 Share on other sites More sharing options...
Hypnos Posted September 7, 2010 Share Posted September 7, 2010 The From: address you use needs to be a valid mail box hosted at your sending mail server. This is not true. You can set the From: header to whatever you want. As long as you're just sending emails, the out of the box configuration in Sendmail on CentOS should not need any modifications. See cliffdodger's reply on setting the From: header when using mail(). Quote Link to comment https://forums.phpfreaks.com/topic/211143-php-mail-problem/#findComment-1108090 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.