Jump to content

PHP mail() Problem...


whit3fir3

Recommended Posts

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 [email protected].  Previously before monkeying with Sendmail some all messages were coming from [email protected]

 

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 [email protected]?

 

Thanks,

 

whit3fir3

Link to comment
https://forums.phpfreaks.com/topic/211143-php-mail-problem/
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/211143-php-mail-problem/#findComment-1101106
Share on other sites

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: [email protected]\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.

 

Link to comment
https://forums.phpfreaks.com/topic/211143-php-mail-problem/#findComment-1103736
Share on other sites

  • 2 weeks later...

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().

Link to comment
https://forums.phpfreaks.com/topic/211143-php-mail-problem/#findComment-1108090
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.