php - PHP xammp sendmail 错误:邮件缺少发件人地址
问题描述
我已经在我的家用电脑上运行的 localhost 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 的部分。当我摆脱它们时,它会起作用
解决方案
I'm not sure if I should delete this question because of the speed I was able to solve it but I hope this helps someone who had the same problem as I did.
here is how I solved the problem
$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");
}
I got the solution from here. tutorial republic
推荐阅读
- r - 理解使用 rlang::eval_tidy 时的赋值
- flutter - 如何在 Flutter 的所有页面上显示浮动按钮?
- nuxt.js - 如何在 Nuxt js 中添加一个函数
- python - ValueError:错误的项目数通过 2,位置意味着 1 具有相同的列数
- asp.net - Angular 11:无法从 API 控制器连接到 SQL Server——GET 方法
- javascript - 如何使用javascript在我的计算器上有清除按钮
- angular-material - Angular mat-header 显示图标的名称而不是图标
- react-native - 创建反应本机应用程序类型的问题
- elasticsearch - 如何在 Kibana 的索引模式中更新 timeFieldName
- docker - 无法创建 HyperLedger 网络