Wednesday, February 23, 2011

Outlook 2010 talking to Exchange 2000 via SMTP.

After some requests in my personal e-mail, I've decided to explain here the steps needed to make Outlook 2010 work with an SMTP Exchange 2000 server.
(Sorry my english, as is not my natural language)

The case goes back to January, when I needed to configure Outlook 2010 to work with the company's server that is based in a different country. This is a little important detail, as the foreign IT department wouldn't be any helpfull. The server was an Exchange 2000 but all the clients are working via SMTP and POP.
If you need to connect O2010 to Exchange 2000 using Exchange's protocol, please stop reading right here.
So, I knew that e-mails could be received, but by all the means, they just won't go out.
I grabbed a copy of Wireshark and started to analyse what's wrong in here.
Long story short:
...the server tells the client what authentication protocols it supports, however Outlook 2010 wants to use DIGEST-MD5.
This is the main difference between Outlook Express (which works great) and Outlook 2010:

Outlook Express:
HELO machine
AUTH LOGIN
username base64 encoded
password base64 encoded
mails go through.
Outlook 2010:
HELO machine
AUTH DIGEST-MD5
response from server
Outlook sends just a *
AUTH LOGIN
password base64 encoded

And it stops right here, no auth, no e-mails to the outside world :)
So, if this is just a little glitch in the matrix, we'll fix it with a python script.
This script, is just a bad re-writen code of a transparent proxy, we're you can mess around with the messages sent between server<->client.
My biggest thanks go to:
Dirk Holtwick (INI reader)
Lobsang (Python Proxy) @ ActiveState
They sure saved me a lot of work by not re-inventing the wheel myself.
So this is the script:

(Update: Removed code, use github link instead)
https://github.com/yaba/SMTPProxy

Sorry, some pieces are in Portuguese, but the code is self-explanatory.
In the config file, you have 2 sections, on srv2clt it processes all the messages from server to client and changes what is need to make Exchange 2000 work with Outlook 2010 (Auth strings)
The clt2srv isn't really needed, but, while I was at it, I thought this could come in handy sometime.
So... now, you have to run the script at localhost or any other server, and tell Outlook to use THAT server as the SMTP server, also, change the config.ini to meet your real SMTP server.
I've also added the port option, just in case.
My costumer uses only windows machines *sigh*, so I've converted python script to a Windows executable and used a tutorial (easy to find online) to make it work like a windows service.
If you have any questions or it doesn't work out for you, just send a e-mail or comment, I'll try to help as soon as possible.