I host my own Exchange server and had accepted the restriction that I couldn’t use the PHP mail() function thinking it was an incompatibility with IIS.  It turns out, however, that my Exchange server (like most Exchange servers) requires a username and password to work.

I found a user on a forum that solved this problem so that he could use Gmail or an external SMTP Server that required SSL, and he wrote this up in a terrific article describing all the gory details.

Once I downloaded the package from the article, I made the following changes to the sendmail.ini file:

  • Set smtp_server to point to my server.
  • Set the smtp_port back to 25 (it was set to 587 to work with Gmail).
  • Set default_domain for addresses that don’t specify it.
  • Set auth_username and auth_password to a valid email address and the password for that email address - this is the key right here that makes it all work.
  • Commented out force_sender.  I don’t want it always coming from a single username since I host multiple sites managed by different users.

Then I had to change my php.ini file.  I commented out everything but sendmail_path.  I tested this and it works great.

Note that the original author of the fake sendmail (Byron Jones) has released bug fixes, so you may want to download his later versions instead.

Resources