LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (http://www.linuxquestions.org/questions/linux-software-2/)
-   -   PHP mail() sending as apache@ipaddress (http://www.linuxquestions.org/questions/linux-software-2/php-mail-sending-as-apache%40ipaddress-545867/)

DukeLeto 04-13-2007 04:54 PM

PHP mail() sending as apache@ipaddress
 
I have scripts:
Code:

<?
        $headers  = "MIME-Version: 1.0\r\n";
        $headers .= "Content-type: text/html; charset=iso-8859-1\n";
        $headers .= "From: Michael <michael@somewhere.com>\n";
        $to = ("michael@somewhere.com");
        $subject = "THIS IS A TEST!";
        $body = "TEST!!2";
        mail ($to, $subject, $body, $headers) or print "Could Not Send Mail";
?>

Yet, my mail sends as apache@192.168.1.40

Apr 13 13:57:16 mgmt postfix/smtp[23975]: 38C24BAB04: to=<michael@somehwere.com>, relay=mail.somehwere.com[192.168.1.22]:25, delay=0.09, delays=0.07/0/0.01/0, dsn=5.0.0, status=bounced (host mail.somewhere.com[192.168.1.22] said: 501 <apache@[192.168.1.40]>: domain literals not allowed (in reply to MAIL FROM command))

Also, another

Apr 13 13:57:18 mgmt postfix/smtp[23944]: CBB37BAC94: to=<to4451@elsewhere.com>, relay=mail.elsewhere.com[192.168.1.22]:25, delay=1, delays=0.01/0/1/0.01, dsn=5.3.0, status=bounced (host mail.elsewhere.com[192.168.1.22] said: 553 5.3.0 <to4451@elsewhere.com>... elsewhere.com No such user here (in reply to RCPT TO command))

I for the life of me cannot figure out why. I am setting from in my headers for the php mail(), this is ALL linux, so setting sendmail_from in php.ini won't help, as that only works on windows.

Anyone have any ideas at all?

Thanks,
Michael

Berhanie 04-13-2007 10:24 PM

You're setting the header from, but not the envelope from. You can set the envelope from by using sendmail -f, i.e. by giving
'-fuser@something.com' as the 5th argument to mail(). See here.


All times are GMT -5. The time now is 11:18 PM.