我正在尝试使用PHP的mail()函数发送测试邮件。
$to = "****@gourab.me"; $sub = "Php Mail"; $msg = "Test Message From PHP"; mail($to, $sub, $msg, "From: **********@gmail.com");
当我尝试通过step中调试它时phpdbg,它显示以下消息:
step
phpdbg
[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标题似乎格式不正确。尝试以下方法:
From
$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);