I'm running XAMPP on my local machine and on a server in the office. Both are Windows machines.
I'm writing some code that uses mail()
to send email from a form. By default, it uses sendmail.exe
(which comes with XAMPP) to send the email. In all cases, the mail is actually sent via a third machine, which is the Exchange server.
From my local machine, PHP can send mail just fine. On the server, upon form submission I get this error:
Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp___port" setting in php.ini or use ini_set() in
... followed by my filename.
I don't understand why it's referencing "localhost." Nowhere in php.ini or sendmail.ini does is "localhost" used - I use the name of the mail server. The SMTP information used on both machines is the same.
As far as I can tell, the two environments have everything important in common:
- The php.ini files are identical
- The sendmail.ini files are identical
- Both machines have the same version of XAMPP installed
- The same batch script will run on both machines and successfully send email via
sendmail.exe
I have stopped and started Apache several times to make sure it's using the updated config files.
When I get the error above, I notice that no log file is produced by sendmail.exe, which makes me think it's never run.
What am I missing?
Solved
My problem was that I thought it was using c:\xampp\php\php.ini
, but it was actually using c:\xampp\apache\bin\php.ini
. This should have been obvious, and I had previously edited the correct file on my local machine, but somehow I got confused when making the changes on the server.
Using php_info()
showed me which config file was loaded, and I edited the correct one. It's working now! Thanks everyone for your help.