Mail Not Sending from Windows Server 2008

We encourage users to post events happening in the community to the community events group on https://www.drupal.org.
TyrelDenison's picture

I cannot get my server to send emails with PHP. This is true within my Drupal install as well as with a simple PHP mail script. I am new to server management, so any assistance would be greatly appreciated. I am running IIS 7.5 on a Windows Server 2008 R2. The mail function in my PHP.ini is as follows:

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

Thanks.

Comments

Windows SMTP Service

alexpilotti's picture

Windows Server comes with an SMTP service. It's just not installed by default, so all you have to do is enabling it and configuring it as needed.

Here's how to install it and configure it on Windows 2008 and Windows 2008 R2. be sure to keep it locked down in order to avoid unintentional relay.

If you need to troubleshoot it, here's a simple guide.

Alessandro Pilotti
MVP ASP.Net / IIS
Windows Azure Internal

Windows SMTP Service

kbobash's picture

Thanks a bunch for your post. The missing key for me was setting up the IP address for the Relay.

Server Sending, But Not With PHP

TyrelDenison's picture

Alex

Thanks for your quick reply. I am able to send emails from my server by dropping text files into the Pickup folder as the troubleshoot guide you referenced suggested. When I try and test the email with PHP as suggested here, it does not work. I believe it is specific to my PHP installation, but I don't know what to alter, as I used the Microsoft Installer rather than building it myself (serves me right).

Tyrel

SMTP settings

alexpilotti's picture

Hi Tyrel,

on Windows PHP main doesn't use sendmail, but sends emails via SMTP (TCP/IP, port 25). In your case you'd like to make sure that you system accepts emails via SMTP (including proper relay settings as explained in the previous post ) and that PHP.INI is properly configured.

The relevant PHP.ini settings are:

[mail function]
SMTP = localhost
smtp_port = 25
sendmail_from = me@example.com

If you prefer to use another SMTP server, (e.g. you provider's) just replace "localhost" with the remote IP or host name. In case you should need SMTP authentication, you can install this Drupal module.

Let me know if you need more help!

Alessandro Pilotti
MVP ASP.Net / IIS
Windows Azure Internal