Error with PHP mail() function
I'm having an error trying to send mail with PHP using the mail()
function.开发者_如何学编程 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 (i.e. the address from which the mail is sent) has to be set.
This can be set either :
- setting a value for
sendmail_from
in yourphp.ini
file (on windows) - or passing a
From
header to themail
function -- in the fourth parameter.
The message you posted indicates you've done none of those -- and that you must do at least one, to specify a From
header.
Quoting the Note in the "*additional_headers*" section of the manual page of mail()
:
When sending mail, the mail must contain a
From
header.
This can be set with theadditional_headers
parameter, or a default can be set inphp.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.
TheFrom
header sets alsoReturn-Path
under Windows.
精彩评论