Drupal with Microsoft Exchange Server

PhilTheDoc - May 1, 2007 - 17:39

I've successfully installed Drupal with Apache 2.2, PHP5 and MySQL5. I'm setting up an intranet. I have a Microsoft network with 2 domains with trust relationships. My Exchange Server machine is on the same domain as the Drupal machine, but they are separate boxes. My problem is I cannot get Drupal/PHP5 to communicate with my SMTP virtual server on the Exchange machine - I've hunted and hunted through these forums and tried everything I can find with no effect. I get the error:

warning: mail() [function.mail]: Failed to connect to mailserver at "smtp.gp-e82014.nhs.uk" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\intranet\drupal-5.1\includes\common.inc on line 1970.

(I don't know what the second suggestion here means, neither can I eaily find line 1970 in a text file!)

I've fiddled with the SMTP settings in php.ini with no effect. I've tried the IP address as well as the actual server name, the FQDN and the virtual server name. DNS works fine, Outlook works fine, and all the relevant bits in Exchange Server have correct permissions set for any user and any machine to use the virtual SMTP server. I tried the SMTP module but get a similar error - it seems Drupal just can't contact the SMTP server.

What Windows user account does Drupal/PHP use to access my network? Could this be my problem? If Drupal has created a local account to use maybe the SMTP server doesn't recognise it as an "Authorised User" of my domain?

I'm really at my wits end. Any help truly appreciated.

BTW - a test setup using the same software but on my home network with a workgroup and no domain works, using my ISP's SMTP server.

Cheers.

Phil

It's just smtp

sepeck - May 1, 2007 - 17:55

From the system that hosts your Drupal site, can you telnet to port 25 of your mail server and send email?
This TechNet article has the manual steps involved.

Outlook communicates with Exchange through MAPI for all sending and receiving of email and doesn't use SMTP directly so whether Outlook works or not is not part of the situation.

The user account shouldn't matter for Drupal either as for sending email it, Drupal just uses SMTP. Most likely your site is being blocked from sending to or through the SMTP server on Exchange. Many Windows anti-virus programs now block port 25 outgoing, so that is one thing to check. A very likely is that your Drupal sites IP Address does not have permission to relay on the Exchange server. Default for Exchange 2003 is to deny relay.

Try the manual test for a more specific error. I know for a fact that Drupal can and will successfully send email through Exchange 5.5, Exchange 2000/2003 with no issues.

-Steven Peck
---------
Test site, always start with a test site.
Drupal Best Practices Guide -|- Black Mountain

You were quite right!

PhilTheDoc - May 2, 2007 - 10:44

Steven - thank you. Using your advice I found port 25 was being blocked by McAfee Viruscan Enterprise 8.1. It blocks port 25 to stop worms mass-mailing.

I now need to set an exception in Viruscan Enterprise. Can you tell me the name of the program I should put into the exceptions list so Drupal can communicate whilst leaving the rule in place for worms? I'm not sure which program in Drupal/PHP/Apache actually does the connecting through the port?

Thanks again.

Phil

erm..

sepeck - May 2, 2007 - 21:18

I would just set port 25 to allowed.

-Steven Peck
---------
Test site, always start with a test site.
Drupal Best Practices Guide -|- Black Mountain

I've been working to get

jjohnsonBLC - January 6, 2008 - 03:30

I've been working to get mail, Drupal, and Exchange to play nicely and I am having a hell of a time. I've followed all of the information in this thread and I'm not sure where to go from here.

I did telnetted to port 25 as far as I could go and I ended up getting an authentication error. Here's the end of my telnet log.

250-mail.mydomain.com Hello [10.1.22.150]
250-SIZE
250-PIPELINING
250-DSN
250-ENHANCEDSTATUSCODES
250-STARTTLS
250-X-ANONYMOUSTLS
250-AUTH NTLM
250-X-EXPS GSSAPI NTLM
250-8BITMIME
250-BINARYMIME
250-CHUNKING
250-XEXCH50
250 XRDST
MAIL FROM:jjohnson@mydomain.com
530 5.7.1 Client was not authenticated

I'm not entirely sure what the next step could be. I'm running Drupal on my local machine that is in the same domain as the mail server.

By default, your Exchange

keith.smith - January 6, 2008 - 03:40

By default, your Exchange server is likely refusing this incoming traffic (you may have to enable anonymous smtp connections on your Exchange Server).

Uh, try some of the suggestions here, perhaps:

http://forums.microsoft.com/TechNet/ShowPost.aspx?PostID=703467&SiteID=17

Thanks for the quick response

jjohnsonBLC - January 6, 2008 - 05:24

This was the most common solution I have found online, and unfortunately, my Systems Administrator does not like this solution and will not allow it. Or at least he didn't like my brief description over e-mail (he's on vacation). He told me he would explain why this is unacceptable when he returns; I'm guessing he doesn't like the sound of "anonymous connections" and decided it must be bad.

Does anyone know of any way around this?

Solution found

jjohnsonBLC - January 7, 2008 - 01:02

A coworker of mine mentioned that he had to use our old mailserver (which we kept running for some unknown reason) in order to have his Mac Mail work with our Exchange. On a whim, I tried it, which solved everything.

Update: I ran this by the Sys Admin and he said this solution won't last much longer, we are removing the old mailserver. I think from here, I'll try to see what settings/permissions are different on the two servers.

...

sepeck - January 10, 2008 - 23:39

Your Exchange admin will need to allow anonymous connections from the IP Address of your Drupal server to relay. He can set it to allow ONLY this IP Address to relay. This is documented on TechNet, is a standard practice which I have done many times at our company.

Failing that, you will need to do something more complicated that will use a domain account to authenticate to the SMTP server. This is so rare, I doubt many know how to set this up on Exchange 2003 vs much less would be wanting to do it and am not sure how to get Drupal to pass acredentials (though I have seen people mention doing it with gmail and other accounts in the forums).

-Steven Peck
---------
Test site, always start with a test site.
Drupal Best Practices Guide -|- Black Mountain

Awesome

jjohnsonBLC - January 13, 2008 - 21:50

I really don't know much at all about Exchange, but we just replaced our Sys Admin, so I'll send the new guy this information. Thanks Steven, you've been a lot of help.

> If Drupal has created a

quaoar - May 1, 2007 - 18:02

> If Drupal has created a local account to use maybe the SMTP server doesn't recognise it as an "Authorised User" of my domain

Drupal doesn't create an account. It's just a collection of php-files executed with the help of Apache. So whatever user Apache runs as, should be set as an "Authorised User" for your domain/Exchange server.

Also take a look here. Might be something of interest:
http://www.php.net/mail

You should, while doing testing, just create a small php script, call it mail.php / test.php which only tries to send an email when you run it. That would make for some easy testing.

Apache user account

PhilTheDoc - May 2, 2007 - 10:46

Thanks quaoar - very useful info. I've now got it working.

Phil

 
 

Drupal is a registered trademark of Dries Buytaert.