I have a Windows Webserver 2008 running with PHP installed. PHP works fine, except when I try to use the mail() function in oder to programmatically send emails via PHP. Then I get this error:
Warning: 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 ...
So, what do I have to install to confire in order to send emails via my PHP script?
I dont know much about mail configuration, but I have the bad feeling of being in for torture...
As an alternative, which is Windows-only, you can configure PHP to use a remote SMTP server for sending mail. This bypasses the need to configure IIS SMTP if all you'd have it doing is forwarding to a smarthost anyway.
In php.ini:
See the PHP mail configuration reference at php.net for other stuff you can do in the INI file.
Allright, got it, not too hard after all.
Install SMTP following this guide: http://www.jppinto.com/index.php/2009/02/installing-iis-70-with-smtp-on-windows-server-2008/ (scroll down, it starts with installing IIS 7, the second part is about SMTP).
Check that the "Simple Mail Transfer Protocol (SMTP)" Service is up and running.
EDIT: Go to IIS 7 Manager, go to the website you need SMTP. Go to SMTP settings, be sure to check the "localhost" checkbox and save.
Go to start, administrative tools, internet info services(iis) 6.0.
Check that the SMTP server is up and running.
Right click on the SMTP server, select properties.
Go to the "Access" tab.
There is an option where you can define which hosts are allowed to connect to the SMTP server. Add "127.0.0.1" to the list of allowed hosts.
EDIT 2: There is also an option where you define the hosts to send to. If you e. g. have an IP (range) of the host(s) which should receive your emails, enter it here. Else choose "all except" and do not add any IP addresses.
Then you're good to go.