This is the ultimate (at least for me! :]) solution to configuring mail sending in your XAMPP. Verified and confirmed that this is working. If you go through these steps and still have no results, I'm 95% sure, that problem is outside XAMPP or sendmail (i.e. something is wrong with your configuration). I hope, I don't have to remind you, that every wise guy uses XAMPP only for development purposes and never, ever as stand-alone, production, webserver!
Do not get confused! This article is about fake sendmail, a solution designed for development environments, like XAMPP, to mimic mail delivery subsystem for developers, that is found on production servers. This text has nothing to do with original sendmail, world famous MTA, started 1979 (25 years before fake sendmail!) and still widely used on production servers and anywhere else in hosting area.
The mailtodisk way
First of all, if you're using XAMPP 1.8.0 or higher, you have a ready-to-use, preconfigured mail sending solution available out-of-the-box. It is called mailtodisk (resides in
XAMPP\mailtodisk folder), it is written by Kay Vogelgesang (a XAMPP co-author) and it is -- of course -- a fake mail program, that writes all emails sent from PHP to
XAMPP\mailoutput folder, instead of actually sending them.
If this is fine for you, you don't have to change anything. Just use
mail() PHP function as usually and keep your eye on
XAMPP\mailoutput folder, to check, if your emails are "sent" and are looking exactly, like you would want them to look. After migrating your PHP code to a production server, with (as I assume) correctly configured mail sending program, no change on your side will be needed.
In XAMPP you have access to sendmail program as well. It is described as "a fake sendmail for bugzilla in windows". You can use it for real mail sending. You only have to configure it correctly.
Grab the newest version of sendmail), if you haven't already got it, and update files in
sendmail.ini configuration file and change settings to match your SMTP server. The i.justrealized.com blog says, that you only need to modify three variables:
But that may not be true, because it all depends on your SMTP server requirements.
For example, I had to:
force_senderto the same value as
Or else my emails were not delivered correctly.
XAMPP\php\php.ini file and search for
mail function group.
; in the beginning)
sendmail_path line, that points to
mailtodisk.exe and enable (remove
; from the beginning) the same line (
sendmail_path), that points to
-t switch and special writing -- doubled quotation marks (actually you need four of them). The entire line should read:
sendmail_path = ""C:XAMPPsendmailsendmail.exe" -t"
Finally, restart Apache, so it re-read
php.ini and load up changed configuration.
At this point you should be done. Using
mail() in PHP code should actually send an email for you.
Now, let me discuss things, you should take into account, if there are any problems or in general.
First, in newst versions of XAMPP, PHP's configuration file is no longer kept in
XAMPP\apache\bin\php.ini, as most guides about sending mails says. Instead, it can be found in
XAMPP\php\php.ini file and you should modify that one!
Second, if you run into any troubles using (fake) sendmail, then enabling (un-commenting)
debug_logfile variables in sendmail's configuration and reading, what is dumped to these files, might help in most cases as well.
Finally, read the
php.ini's notice in
mail function section and understand it. When it says:
If XAMPP is installed in a base directory with spaces (e.g.
c:\program files) fakemail and mailtodisk do not work correctly. In this case please copy the sendmail or mailtodisk folder in your root folder (e.g.
c:\sendmail) and use this for
Then it really means that.
If you decide to put XAMPP somewhere else than the root directory of any of your disks, then you may expect a whole lot of problems. Not working sendmail or mailtodisk is one of them. Probably the smallest one.
If you still can't get this stuff working then consult
XAMPP\sendmail\ReadMe.html or its updated on-line version at http://www.glob.com.au/sendmail or any of the links listed below.
Here is a bunch of links, that I found and read on:
- Mentioned fake sendmail homepage.
- "How to use sendmail in XAMPP for Windows" blog post at i.justrealized.com blog.
- "Sendmail??" topic at ApacheFriends.org's forum.
- "How To: PHP Sendmail and XAMPP on Windows" blog post on Memorise blog.
- Stack Overflow's "Trouble installing Fake Sendmail" question (and answer).
Note, that I just run through these quickly, without to deep reading, as in my case, entire problem was limited to changing mail function configuration in
php.ini from default mailtodisk to sendmail. See above.