PHP电子邮件问题

时间:2012-11-06 08:22:10

标签: php mysql

我有一个带有php的HTML注册表单。成功提交后,它会向用户电子邮件地址发送一封确认电子邮件。

好吧,当用户看到他/她的电子邮件时,它显示为:

Yoursite.comr@mediaplan.ovh.net

但我没有将 @ mediaplan.ovh.net 部分添加到电子邮件地址。为什么它会在这个地址中显示出来。 @ mediaplan.ovh.net ?以及如何删除它?

php电子邮件代码:

$to = "$email";                     
$subject = "Signup | Verification";
$message = "Congratulation $f_name $l_name you have been successfully registered. 
Please click the link to active your account.\r\n";
$message .= "http://www.maaks.fr/hotel/verify.php?email=$email&hash=$hash\r\n";

$from = "Yoursite.com";
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-rype: text/html; charset=iso-8859-1\r\n";
$headers .= "Content-Transfer-Encoding; 7bit\r\n";
$headers = "From:" . $from . "r\n";

$mailsent = mail($to,$subject,$message,$headers); 

2 个答案:

答案 0 :(得分:3)

首先,您在 标题部分中缺少斜杠。

$headers = "From:" . $from . "r\n";
                          //  ^ Here

发送邮件时更改From标题

$from = "WebsiteName <Your@mail.com>";
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-rype: text/html; charset=iso-8859-1\r\n";
$headers .= "Content-Transfer-Encoding; 7bit\r\n";
$headers = "From: " . $from . "\r\n";

答案 1 :(得分:1)

尝试将$更改为电子邮件地址。

$from = "noreply@yoursite.com";