sendmail – php发送邮件代码无效

$to = "jijodasgupta@gmail.com";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";
if (mail($to, $subject, $body)) {
  echo("pMessage successfully sent!/p");
} else {
  echo("pMessage delivery failed.../p");
}

写了一个基本的php sendmail代码,但它给了我以下错误:

Warning: mail() [function.mail]: “sendmail_from” not set in php.ini or
custom “From:” header missing in C:\xampp\htdocs\mail.php on line 5
Message delivery failed…

我更改了“php.ini文件并放入sendmail_from=jijodasgupta@gmail.com但仍然存在问题.
第一次编写邮件脚本.

难道我做错了什么?有一个更好的方法吗?

解决方法:

additional_headers (optional)

String to be inserted at the end of
the email header.

This is typically used to add extra
headers (From, Cc, and Bcc). Multiple
extra headers should be separated with
a CRLF (\r\n).

Note: When sending mail, the mail must
contain a From header. This can be set
with the additional_headers parameter,
or a default can be set in php.ini.
Failing to do this will result in an
error message similar to Warning:
mail(): “sendmail_from” not set in
php.ini or custom “From:” header
missing. The From header sets also
Return-Path under Windows.

我希望有所帮助.

上一篇:如何以快速的python方式向成千上万的收件人发送邮件,每个收件人都显示为邮件头中的接收者?


下一篇:jQuery / PHP邮件发送简单方法?