[英]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: 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. 但不幸的是,在邮件中:“通过venus.nswebhost.com从sgkm@ku.edu.tr发送”,因此,我仍然在发件人的邮件部分看到venus.nswebhost.com。 Can't I delete that ?
我不能删除它吗?
What should I do ? 我该怎么办 ?
Thanks 谢谢
您需要在mail()调用中使用“ additional_parameters”标志来指定“信封”。
$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. 除非我弄错了,否则您不会在
mail()
函数中使用$headers
变量。
From: http://php.net/manual/en/function.mail.php 来自: 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 ); mail($ to,$ subject,$ message, $ headers );
You forgot to use the $headers variable you've set up! 您忘记使用已设置的$ headers变量! Try:
尝试:
$sent = mail($to, $subject, $message, $headers);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.