Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

mail function overwrites the from variable..

Status
Not open for further replies.

crackn101

Programmer
Dec 27, 2002
63
0
0
US
Hi Guys.
I am calling the mail() function from my php script
hosted on a linux box.
The problem that i have is no matter what i specify for
the headers, the From and Reply-to headings in the recieved
email always say "added by portage for apache [apache@vhost.xxxxxx.com]". This seems to be either
an apache config error, or it possibly could could be
in the php.ini file.
Has anyone else ran across anything like this?
A search here, and on google, didn't come back with anything helpful.
Any suggestions would be appreciated.
TIA.
Tony
<code>
<?php
$myemail= "xxxxx@xxxxx.com";
$message = "This is a test email.";
$from = "me@mydomain.com";
$replies = "me@mydomain.com";
$subject = "This is the subject line";
$headers = "From: Me <$from>\n";
$headers .= "Reply-To: $replies\n";
$headers .= "X-Sender: $from\n";
$headers .= "X-Mailer: PHP4\n";
$headers .= "X-Priority: 3\n";
$headers .= "Return-Path: $from\n";
$headers .= "MIME-Version: 1.0\n";

$retval = mail($myemail, $subject, $message,$headers);
echo "<h2> Your email has been sent. Bool Return Value = $retval</h2>";
?>
</code>
 
It could also be your mail server.

sendmail, for example, does not pay attention to the "From:". To set a custom sender header, you have to use the "-f" additional parameter with mail(). See
qmail also doesn't pay attention to "from". It uses an environment variable.

Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Hi thanks for the quick reply.
I tried the -f parameter but with the same results.
I think that we are going to install an smtp mailer package and be done with it.

Thanks.
 
Err... actually... we are currently using postfix,
so i think we are going to try something else.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top