Php mail function error, mail sent from wrong address
I would like to sent e-mail to registered users with the following code:
$to = $ownerMail;
$subject = 'SGKM - Online Ticket';
$message = 'SGKM - Online Ticket';
$headers = 'From: sgkm@ku.edu.tr' . "\r\n" .
'Reply-To: sgkm@ku.edu.tr' . "\r\n" .
'X-Mailer开发者_如何学Python: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
but unfortunately, in mail: "from sgkm@ku.edu.tr via venus.nswebhost.com" so, I still see venus.nswebhost.com in sender's mail part. Can't I delete that ?
What should I do ?
Thanks
You need to use the 'additional_parameters' flag in the mail() call to specify an "envelope".
$sent = mail($to, $subject, $message, $headers, "-f webmaster@example.com");
Unless I'm mistaken, you're not using the $headers
variable in your mail()
function.
From: http://php.net/manual/en/function.mail.php
<?php
$to = 'nobody@example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster@example.com' . "\r\n" .
'Reply-To: webmaster@example.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
?>
mail($to, $subject, $message, $headers);
You forgot to use the $headers variable you've set up! Try:
$sent = mail($to, $subject, $message, $headers);
精彩评论