Not a member yet? Register now and get started.

lock and key

Sign in to your account.

Account Login

Forgot your password?

make php mail() work on windows

17 Feb Posted by in Nice tools & resources, Windows administration | Comments Off on make php mail() work on windows

If you have recently moved your PHP web site to a windows VPS or dedicated server (for whatever reason: of course, it is more natural to host PHP web sites on unix, but it can happen that windows box is the only way), you could possibly realized that your php mail() function had stopped working. Meaning that all PHP logs look fine, but emails are not sending out.

First of all, check your PHP.INI file, which should be located by default at C:/Program Files/PHP directory. Scroll down till you see the [mail function] text. Make sure, that SMTP and smtp_port settings are correct. This is how this section should usually look like:

[mail function]
; For Win32 only.
SMTP = localhost
smtp_port = 25
These are the things to check:
1) Some hosting providers, like goDaddy, do not allow users send emails directly from the hosted machine. Meaning that no SMTP traffic goes out even if you’ve configured everything properly. GoDaddy provides their customers with a SMTP Relay address, which should be used as in the PHP.INI file, for example:
If you are going to send the emails from your server directly,then
should work for you.
2) If this is not the case for you, make sure, that you have SMTP server software configured properly. It can be really difficult to configure Microsoft SMTP server, if you are not a Microsoft guru. So I would suggest using some simple SMTP server instead. There are a lot of them on the market, for example this one: . Postcast server free edition is completely free and is very easy to install and configure.
3) Make sure that your Firewall is not blocking port 25. Just go to Start –> Administrative tools –> Windows Firewall (at least this is the path I’m using on Windows 2008). This is a good idea to have the firewall switched ON, but in order to test if your issue is related to the firewall, the easiest thing would be temporarily switch it OFF. If it seems that the firewall was the case, switch it back ON and create an exception allowing SMTP server of your choice connections on port 25.
That’s it!