0

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

1 Answer 1

2

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 your php.ini file (on windows)
  • or passing a From header to the mail 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 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.

Sign up to request clarification or add additional context in comments.

2 Comments

can you tell me steps on how to do one of those?
Well, edit your php.ini file to set the sendmail_from directive ;; or pass a From header to the mail() function (see the examples in the manual -- Example #2 has a From header)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.