简体   繁体   English

PHP mail()函数出错

[英]Error with PHP mail() function

I'm having an error trying to send mail with PHP using the mail() function. 我在使用mail()函数尝试使用PHP发送邮件时遇到错误。 Here's the error message I'm getting: 这是我得到的错误消息:

sendmail_from" not set in php.ini or custom "From:" header missing 
in C:\xampp\htdocs\strawman\addstudent.php on line 265..

When sending a mail, a From header (ie the address from which the mail is sent) has to be set. 发送邮件时,必须设置From标题(即发送邮件的地址)。

This can be set either : 这可以设置为:

  • setting a value for sendmail_from in your php.ini file (on windows) php.ini文件中设置sendmail_from的值(在windows上)
  • or passing a From header to the mail function -- in the fourth parameter. 或者将From头传递给mail函数 - 在第四个参数中。


The message you posted indicates you've done none of those -- and that you must do at least one, to specify a From header. 您发布的消息表明您没有完成这些操作 - 并且您必须至少执行一次,以指定From标头。

Quoting the Note in the "*additional_headers*" section of the manual page of mail() : mail()手册页的“* additional_headers *”部分中引用注释:

When sending mail, the mail must contain a From header. 发送邮件时,邮件必须包含From标头。
This can be set with the additional_headers parameter, or a default can be set in php.ini . 这可以使用additional_headers参数设置,或者可以在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. 如果不这样做将导致类似于Warning: mail(): "sendmail_from" not set in php.ini or custom "From:" header missing.的错误消息Warning: mail(): "sendmail_from" not set in php.ini or custom "From:" header missing.
The From header sets also Return-Path under Windows. From标头在Windows下也设置了Return-Path

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM