[PHP Warning:mail():“ sendmail_from"不在php.ini中设置或自定义“发件人:”标题丢失 [英] [PHP Warning: mail(): " sendmail_from" not set in php.ini or custom "From:" header missing
本文介绍了[PHP Warning:mail():“ sendmail_from"不在php.ini中设置或自定义“发件人:”标题丢失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用PHP的mail()函数发送测试邮件。
$ to =*** *@gourab.me;
$ sub =Php Mail;
$ msg =从PHP测试消息;
mail($ to,$ sub,$ msg,From:**********@gmail.com);
当我尝试通过步骤进行调试
在 phpdbg
中,显示消息:
[PHP警告:邮件():sendmail_from未在php.ini中设置或自定义From:标题
缺少C:/xampp/htdocs/tinyProj/mail.php第4行]
$ c $
$ b 我不明白为什么?看来你的从
头文件格式不正确。尝试改为:
$ headers ='MIME-Version:1.0'。 \r\\\
;
$ headers。='From:您的姓名< info@address.com>'。 \r\\\
;
$ headers。='Content-type:text / html; charset = iso-8859-1'。 \r\\\
;
mail($ to,$ subject,$ body,$ headers);
I am trying to use PHP's mail() function to send a test mail.
$to = "****@gourab.me";
$sub = "Php Mail";
$msg = "Test Message From PHP";
mail($to, $sub, $msg, "From: **********@gmail.com");
When I try to debug it through step
in phpdbg
, it shows the message:
[PHP Warning: mail(): " sendmail_from" not set in php.ini or custom "From:" header
missing in C:/xampp/htdocs/tinyProj/mail.php on line 4]
I cannot understand why?
解决方案 It seems your From
header is not correctly formatted. Try this instead:
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'From: Your name <info@address.com>' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
mail($to, $subject, $body, $headers);
这篇关于[PHP Warning:mail():“ sendmail_from"不在php.ini中设置或自定义“发件人:”标题丢失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文