PHP mail () function does not use "from" address
$to = "me@mydomain.com";
$subject = "Auction Registration Confirmation";
$from = "From: donot-reply@mydomain.com";
$body = "Test Message";
if (mail($to, $subject, $body, $from)) {
echo("<b>Message sent</b>");
header( "Location: http://www.mydomain.com/thankyou.html" );
} else {
echo("<b>Message failed</b>");
}
Now the problem is that when the email is sent, the address is not what I require, but the server login.
Any ideas regarding replacing the server login with an email id.
0
pete
a source
to share
4 answers
You can try
mail($to, $subject, $body, $from, "-f $from");
this works in some configurations, really depending on the server setup. If not, edit your MTA settings as recommended above, or skip mail () altogether and use a PHPmailer-like class that connects directly to the SMTP server.
0
a source to share