My name is Svetoslav Marinov, which has short forms such as Slavi and Svetlio. I am originally from Bulgaria, Europe. Currently, I live in Ontario, Canada and I am working as a Web Developer. With my blog I want to share my knowledge and exchange ideas. Svetoslav is a DZone MVB and is not an employee of DZone and has posted 12 posts at DZone. You can read more from them at their website. View Full User Profile

How to send emails from PHP on Windows

  • submit to reddit


  • Windows OS
  • PHP
  • An account that you can send from (smpt server/user/pass)
  • 5-15 minutes

Download sendmail for Windows from
Copy sendmail.exe and sendmail.ini into C:/usr/lib/

Edit sendmail.ini and enter your mail account credentials.

You might want to configure these 2 fields as well (or sending may not work)
By the way I uncommented debug_logfile so I can see what data is being sent to my SMTP server.

edit c:\php\php.ini

sendmail_from =

; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
sendmail_path = C:/usr/lib/sendmail.exe -t -i

Restart apache
Start sendmail.exe either from [Start] > Run > C:/usr/lib/sendmail.exe or Go to C:/usr/lib in Windows Explorer and then DoubleClick on the exe file.

... and now the best part - Testing

Here is an example from

Create a file called m.php in htdocs
Published at DZone with permission of Svetoslav Marinov, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)


Olaf Lederer replied on Wed, 2011/05/11 - 2:01am

Sending e-mail with PHP on windows was always a problem. I hope your solution will help some of the "PHP on windows" users. I think it's much better to use a class like PHPMailer (SMTP mode) or the smtp server from the ISP (people need to add this server entry in their php.ini file)

Carla Brian replied on Sat, 2012/07/07 - 12:52am

Thank you for these steps. I am not familiar with this yet. Good thing I saw this post. This is really helpful in a way. - Mercy Ministries

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.