Take the 2-minute tour ×

I can't seem to get my php script to send email.

echo "Does this page work?";
mail('my email address', 'test subject', 'test message');

First, I have set the mail function settings in the php.ini file as follows:

I checked my email account settings on outlook. It does not require authentication, its port is 25, and its type of encrypted connection is 'Auto'. Given this I configured my php.ini file accordingly:

SMTP = ssl://smtp1.iis.com
smtp_port = 25

Then I set:

sendmail_from = my email address

The echo statement prints out in the browser, so I know the php file is recognized and processed. But the browser also shows the following error:

Warning: mail() [function.mail]: "sendmail_from" not set in php.ini or custom "From:" header missing in C:\xampp\htdocs\mailtest.php on line 3

I have clearly set the sendmail_from so I don't know what else to do. I have also tried removing the 'ssl://' part from the SMTP setting in the php.ini file, and configuring the php5.ini file. Which of these .ini files should I be configuring anyways?

share|improve this question
add comment

6 Answers

You did uncomment sendmail_from in php.ini, yes? It should look like this:

; For Win32 only.
sendmail_from = me@example.com

Not like this:

; For Win32 only.
;sendmail_from = me@example.com

The only reason for PHP to say its not set .. is, well, if it's not set.


The only other issue that I could think of (for that warning) is that you may be editing the wrong php.ini file. If it's actually set , PHP should not be issuing that warning. I believe the default PHP configuration on your platform is \xampp\php\php.ini


Your SMTP host may be using something called pop-before-smtp. Try this using another mail provider that does use SMTP (password) authentication to rule that out.

share|improve this answer
yes - though that took me a few looks before I noticed it...didn't help –  RoryG Jun 3 '10 at 21:10
@RoryG Its very likely that you are editing the wrong php.ini file if your changes aren't reflecting in phpinfo() –  Tim Post Jun 3 '10 at 21:41
Yep - I came to that conclusion and now the warning has stopped, but still no email is being sent...For others who may have the same problem, it turned out for my platform anyways, its \xampp\apache\bin\php.ini –  RoryG Jun 3 '10 at 23:24
add comment

To answer your question about 'which of these .ini files should I be configuring' you can run phpinfo() to see your server's configuration. That will list the paths to all of your config files.

share|improve this answer
so I ran phpinfo() and noted that I am running php5.2.5 so I assume I should be editing the php5.ini? More intriguingly, I looked down at the specs and one read: SMPT localhost But that is the one I think I am changing to something else (as indicated in my original question). This may be a clue to my problem! Thanks –  RoryG Jun 3 '10 at 21:21
When you look at the phpinfo() page, the sixth row on the very first table (the one at the top of the page) lists the "Configuration File (php.ini) path". The file listed there is the file used in configuration. Make sure that's the one you're editing! –  eykanal Jun 3 '10 at 22:47
add comment
sendmail_from = email@address.my

Mind the : should be a =

share|improve this answer
fixed that typo too. I should have cut and paste, but didn't want to expose my details... –  RoryG Jun 3 '10 at 21:12
No problem, wasn't sure if you hand-typed it or copied and pasted it over.. Sometimes it just takes a second pair of eyes. :-P –  Phliplip Jun 3 '10 at 21:16
add comment
up vote 1 down vote accepted

I now have an ANSWER to my question...

I used phpinfo() to find out which php.ini file I was supposed to be editing. As it turned out, there were 3 such files available in my server folder. Two were under the PhP folder (named php.ini and php5.in respectively) and the other was in the apache/bin folder. Using the phpinfo() function, I was able to determine that I was editing the wrong .ini files (I looked at the parameters I was setting and the were not changing). Once I edited the correct one (the one in apache/bin) the Warning: mail() [function.mail]: "sendmail_from"...error stopped occurring.

Then, to get the mail sent, I edited the correct .ini file as originally posed in my question:

SMTP = myoutgoingmail.com (the same setting as my mail program - outlook)
smtp_port = (the same as my mail program - oultook)

sendmail_from = myemailaddress.com
share|improve this answer
add comment

I hate to point out something so terribly obvious if it is an intentional misspelling, but in your SMTP line, shouldn't it be ssl://*smtp*1.iis.com ?

share|improve this answer
fixed the typo - thanks for pointing it out –  RoryG Jun 3 '10 at 21:05
No problem, wasn't sure if you hand-typed it or copied and pasted it over.. Sometimes it just takes a second pair of eyes. –  Nic Jun 3 '10 at 21:05
add comment

You need to pass a 'From' header for the mail() function. I believe the sendmail_from setting only applies to Windows environments. Try this instead:

mail('email@example.com', 'Subject', 'Message', array('From' => 'me@example.com'));
share|improve this answer
I don't think php would be complaining about it being unset if he was not on a Windows environment. Additionally, the warning references a Windows path name. –  Tim Post Jun 3 '10 at 21:05
tried that - it didn't work. I am in a windows environment so I am guessing the 'From' header does the same thing as the php.ini configuration –  RoryG Jun 3 '10 at 21:06
add comment

Your Answer


