gpt4 book ai didi

sendmail - php发送邮件代码不起作用

转载 作者:可可西里 更新时间:2023-10-31 23:00:23 25 4
gpt4 key购买 nike

$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.

希望对您有所帮助。

关于sendmail - php发送邮件代码不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1104555/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com