PHP xammp sendmail error: Message is missing sender's address
PHP xammp sendmail error: Message is missing sender's address
我已经在我家用电脑上的本地主机 xammp 服务器 运行 上设置了 Sendmail 客户端,但我收到以下错误:xx-xx-xx xx:xx:xx: Message is missing sender's address
。当我使用我想要发送的硬代码时,我已经让它工作了,就像这样:
$msg = "hello world";
mail("example@gmail.com","My subject",$msg, 'From: admin@myEmailClient.com');
但是当我尝试执行我的登录验证脚本时,它不起作用并且出现了上述错误。
emailvalidation.php
$to = $email;
$sub = 'email verification';
$msg = "<a href='http://localhost/verify.php?vkey=$vkey'>account verification </a>";
$headers = "From: admin@myEmailClient.com \r\n";
$headers = "MIME-Version: 1.0". '\r\n';
$headers = "Content-type:text/html;charset=UTF-8 ". '\r\n';
mail($to, $sub, $msg, $headers);
我的 email
变量是由用户设置的,如果有帮助的话,我不认为这是被解析的项目的问题,因为当我检查我的数据库时,所有行都已正确填写。
感谢您的宝贵时间
编辑
我认为 r\n 部分有问题,这些是在电子邮件中启用 HTML 的部分。当我摆脱它们时它起作用了
我不确定是否应该删除这个问题,因为我解决它的速度很快,但我希望这能帮助那些和我有同样问题的人。
这是我解决问题的方法
$message = "<a href='http://localhost/verify.php?vkey=$vkey'>account verification </a>";
$to = $email;
$subject = 'account validation';
$from = 'admin@myEmailClient.com';
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: '.$from."\r\n".
'Reply-To: '.$from."\r\n" .
'X-Mailer: PHP/' . phpversion();
if(mail($to, $subject, $message, $headers)){
echo 'Your mail has been sent successfully.';
} else{
header("location: index.PHP");
}
我从 here 得到了解决方案。教程共和国
我已经在我家用电脑上的本地主机 xammp 服务器 运行 上设置了 Sendmail 客户端,但我收到以下错误:xx-xx-xx xx:xx:xx: Message is missing sender's address
。当我使用我想要发送的硬代码时,我已经让它工作了,就像这样:
$msg = "hello world";
mail("example@gmail.com","My subject",$msg, 'From: admin@myEmailClient.com');
但是当我尝试执行我的登录验证脚本时,它不起作用并且出现了上述错误。
emailvalidation.php
$to = $email;
$sub = 'email verification';
$msg = "<a href='http://localhost/verify.php?vkey=$vkey'>account verification </a>";
$headers = "From: admin@myEmailClient.com \r\n";
$headers = "MIME-Version: 1.0". '\r\n';
$headers = "Content-type:text/html;charset=UTF-8 ". '\r\n';
mail($to, $sub, $msg, $headers);
我的 email
变量是由用户设置的,如果有帮助的话,我不认为这是被解析的项目的问题,因为当我检查我的数据库时,所有行都已正确填写。
感谢您的宝贵时间
编辑
我认为 r\n 部分有问题,这些是在电子邮件中启用 HTML 的部分。当我摆脱它们时它起作用了
我不确定是否应该删除这个问题,因为我解决它的速度很快,但我希望这能帮助那些和我有同样问题的人。
这是我解决问题的方法
$message = "<a href='http://localhost/verify.php?vkey=$vkey'>account verification </a>";
$to = $email;
$subject = 'account validation';
$from = 'admin@myEmailClient.com';
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: '.$from."\r\n".
'Reply-To: '.$from."\r\n" .
'X-Mailer: PHP/' . phpversion();
if(mail($to, $subject, $message, $headers)){
echo 'Your mail has been sent successfully.';
} else{
header("location: index.PHP");
}
我从 here 得到了解决方案。教程共和国