There are a tonne of sites offering information on how to set the iPhone up with Exchange 2003 but they seem to have sporadic information. Since I apparently hit every problem under the sun with this setup I thought I would collate the info I found here for future reference and to help anyone with similar problems.
If there are mistakes please point them out, I'll change the guide.
This works on any iPhone with the version 2.0 software – the iPhone 3G comes with this out of the box, but original iPhones will need to be upgraded.
Apple have a PDF document outlining some of these steps here.
There several ways to connect the iPhone to an Exchange Server. IMAP doesn't give you full exchange features like calendars etc so here I'm focussing purely on the ActiveSync setup within the iPhone.
First steps are to make sure the server is configured correctly and all necessary services are active. To connect your iPhone to an Exchange Server you need to have the following enabled/setup:
1) IMAP
2) Outlook Web Access
3) Outlook Mobile Access
4) RPC over HTTP
5) Firewall
Check the user account and make sure all of the below is enabled. Go to start and manage the server, select active directory user and computers, find the user, right click and go to properties. Click 'exchange features' and it should look like this.
If not you can try enabling directly from here or try the following :
Enable IMAP
Go to Start > run > type services.msc search the list for IMAP4 and make sure it is started and set to automatic.
Enable Outlook Mobile Access
Go to Start > programs > mixrosoft exchange and system manager. Expand Global Settings and click Mobile Services.
RPC over HTTP
Luckily I had no problems with this aspect, hopefully for you it will all be up and running from the intital server install. If not you could read this Microsoft Article on how to deploy and troubleshoot. However I would leave this until the absolute last as it is highly unlikely it will be your problem.
To test it is working though go to start > run and type outlook /rpcdiag. You may need to choose a profile at this point, if not type the user name and password in the box that appears (User name should be in the format domainname'username).
A window will open in the background if RPC over HTTP is working.
A very good article on how to set up and troubleshoot can be found here.
Firewall Setup
The following ports need to be set up to forward to the server: 25 (smtp), 80 (http) and 443 (imap).
Configuring the iPhone
Set up an email account by tapping Settings, Mail, Contacts, Calendars, and then Add Account. Choose Microsoft Exchange.
Once you click next it will try to automatically set the phone up. If you have exchange 2007 this will work, if not you will receive an error saying 'account verification failed'. Just click to accept and move on.
You will now have to manually set up the mail account.
Email - youremail@yourdomain.com
Server - The static IP of your server (If you don't have one, you need to get one). You could also try http://email.yourdomain.com
User name and Password - The user name and password you use for the mailbox.
Troubleshooting
If this doesn't work and you have followed all the steps you could try the following:
Make sure Outlook Web Access is working locally. Type the local address of your exchange server into a web browser. i.e '192.168.1.1/exchange'. This should bring up a logon box an allow you to connect. If not OWA is not functioning on the server, see section above.
A bit about loop back
This assumes everything above has been done.
If you are connected locally via wireless and OWA does not work then the firewall is not allowing loop back. Since you are connecting from inside your network then out to a public IP and back in again, loopback must be enabled. The easiest way to check this is to connect from a PC within the network to the exchange server via the public IP ie 84.123.123.1/exchange. If this fails but works on the private IP then it is likely loopback on the router. Google your router and keyword loopback.
Try connecting via your phone provider, 3G, AT&T etc then try OWA again, this doesn't require loopback and should work.
If anyone has any additions or please feel free to post.