[PHP 警告:mail(): "sendmail_from"未在 php.ini 或自定义“From:"中设置标题丢失 [英] [PHP Warning: mail(): " sendmail_from" not set in php.ini or custom "From:" header missing

查看:23
本文介绍了[PHP 警告:mail(): "sendmail_from"未在 php.ini 或自定义“From:"中设置标题丢失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 PHP 的 mail() 函数发送测试邮件.

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");

当我尝试通过 phpdbg 中的 step 调试它时,它显示以下消息:

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]

我不明白为什么?

推荐答案

您的 From 标题的格式似乎不正确.试试这个:

It seems your From header is not correctly formatted. Try this instead:

$headers =  'MIME-Version: 1.0' . "
"; 
$headers .= 'From: Your name <info@address.com>' . "
";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "
"; 

mail($to, $subject, $body, $headers);

这篇关于[PHP 警告:mail(): &quot;sendmail_from"未在 php.ini 或自定义“From:"中设置标题丢失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆