Normally, php mail's function doesn't *work* on Windows because there is no sendmail server running by default.

Some people got it working using Fake Sendmail and StunnelĀ  & an external service such as Gmail/Yahoo, and others using msmtp.

I didn't want my gmail or other credentials saved on the computer or a too complicated solution that may be hard to troubleshoot so I decided to use the Mandrill service to send emails from my development machine.

So the steps are the following

  1. Download Fake Sendmail
  2. Extract the archive contents in c:\usr\lib
    Important Note: if you're running Windows 7 or 8 (not sure for Vista) you need to set XP Compatibility Mode. To do that right click on Sendmail.exe and click on properties and then enable XP compatibility mode (shown below).
  3. Edit php.ini (shown below)
  4. Signup for Mandril
  5. Create an API key (which will be your password) by going to Settings
  6. Configure Fake Sendmail (shown below)
  7. Restart Web Server or restart computer if that's easier.

Enable XP Compatibility Mode on Fake Sendmail

Enable XP Compatibility Mode on Fake Sendmail

php.ini configuration (partial)

[mail function]
; For Win32 only.
; http://php.net/smtp
;SMTP = localhost
; http://php.net/smtp-port
;smtp_port = 25

; For Win32 only.
; http://php.net/sendmail-from
sendmail_from = admin+umob@domain.com

; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
; http://php.net/sendmail-path
;sendmail_path =
sendmail_path = "c:\usr\lib\sendmail.exe -t"


Fake Sendmail Configuration (Windows)
Make sure you edit the following.

  • default_domain=YOUR_DOMAIN_GOES_HERE
  • auth_username=YOUR_MANDRIL_EMAIL_GOES_HERE
  • auth_password=YOUR_MANDRIL_API_KEY_GOES_HERE

Note: if you're configuring your own copy of the config file make sure you don't use encryption i.e. smtp_ssl=none (as shown in the snippet). I've had no problems using the command line scripts, however, the php script would hang if Fake Sendmail used encryption.

Resources

 

Referral Note: When you purchase through an referral link (if any) on this page, we may earn a commission.
If you're feeling thankful, you can buy me a coffee or a beer