31AugHow to setup IMAP4 Exchange 2003 email to sync with your iPhone

Header image

If you are like me, you were surprised that Apple even included quasi Exchange 2003 email support on the Iphone. Nonetheless, we will thank Apple for what they have given us. GO team!

Anyways, this post will walk you through how to setup your Exchange 2003 to have IMAP4 and SMTP support so end-users using an iPhone or other devices that support those protocols.

—–This How To assumes no responsibility whatsoever. So if you *fubar* your production server, do not blame me.—

Click after the jump if you agree to the above… 

Here is what you need:

  • Exchange 2003 SP2 setup and fully functional.
  • Administrator access to both Front-end and Back-end servers
  • Firewall Administrator Access to your incoming firewall
  • And an iPhone with Wifi access (for initial sync and testing)

Setup Exchange 2003 for IMAP4 (incoming emails to your iPhone)

  1. Go into Exchange System Manager. Expand to Administrative Groups –> GroupName –> Servers –> Exchange_server_2003 –> Protocols –> IMAP4.
  2. Create a new IMAP4 Virtual Server. New –> IMAP4 Virtual Server…
  3. Give it a name
  4. Assign IP to “AllUnassigned
  5. A new IMAP4 Server should be assigned in the right pane. Right click on it, and go into properties.
  6. Leave General tab as is. (unless you want to change the default TCP ports of 143 and SSL port of 993)
  7. In Access tab, click on “Authentication…” button. If you want to use SSL or have Weboutlook going into SSL automatically, then you do not need the “Requires SSL/TLS encryption” button. Otherwise, you need to check box it. Otherwise your password will be going thru cleartext!!
  8. Okay, and get out of this window.
  9. Repeat the same steps on your backend server.

Setup Exchange 2003 for SMTP (outgoing emails from your iPhone)

  1. Go into Exchange System Manager. Expand to Administrative Groups –> GroupName –> Servers –> Exchange_server_2003 –> Protocols –> SMTP.
  2. Create a new SMTP Virtual Server. New –> SMTP Virtual Server…
  3. Give it a name
  4. Assign IP to “AllUnassigned
  5. A new SMTP Server should be assigned in the right pane. Right click on it, and go into properties.
  6. Leave General tab as is. (unless you wnat to change the default TCP port of 25)
  7. In Access tab, click on “Authentication…” button. It should look like below
    Iphone Exchange 2003 Authentication window
  8. Click on the “Users” button and add the appropriate mobile users who will have an iPhone that will be sending. Make sure you only include those you want to be able to send. !!!Otherwise, you will have a nice open SMTP server for all the spammers to spam if you put “everyone”!!! Click OK and OK when you are done with the users and Authentication.
  9. Skip Messages Tab
  10. Click on “Delivery tab” and on “Advanced” button
  11. If this Exchange server you are setting up is a front-end server, you will want to fill the Smart host field with your Back-end Server or whatever server processes your outgoing SMTP requests. If your Back-end server has an IP address of 172.16.62.5, put the IP address in a square bracket. Ie. [172.16.62.5] Click on OK when you are done.
  12. You do not need to do this on your back-end server if your back-end server is sending the outgoing emails.

Firewall:
Depending on what firewall you have: Cisco Pix, Nokia checkpoint, etc. you’ll need to open the following TCP ports to the front-end Exchange server to the world.

  • IMAP4 (ie 143)
  • SMTP (ie. 25)
  • SSL IMAP4 (ie.993)

Exchange Services:

  • You need to set “Microsoft Exchange IMAP4″ Service to Automatic and Start the service.
  • You need to set “Microsoft Exchange SMTP” Service to Automatic and Start the service. (if it isn’t already)

Apple iPhone:
I would recommend putting your iPhone onto a wifi network instead of EDGE until you get this up. Edge works fine on updates, but

  1. Go into the main Springboard page (With all the icons)
  2. Tap Settings
  3. Tap Mail
  4. Tap Other
  5. Tap Exchange
  6. Fill in the Name, Email address and a brief description of your work email
  7. In the Incoming Mail Server
    Fill in the Host Name of your Weboutlook server. (Ie. owa.testserver.com)
  8. Fill in the Username with your domain and username. (IE. TESTDOMAIN\USERNAME)
  9. Fill in your password
  10. In the Outgoing Mail Server
  11. Fill in the Host Name of your Weboutlook server. (Ie. owa.testserver.com)
  12. Fill in the Username with your domain and username. (IE. TESTDOMAIN\USERNAME)
  13. Fill in your password
  14. Tap Save and it should say “Verifying Exchange account information” on top.
  15. The screen should go back to your Mail screen, and you are set.
  16. Go into Mail and you will see your email box in the account tab all the way on top.

Troubleshooting

  • Make sure your firewall to IMAP4 and SMTP is open. You can usually check this if you do the telnet test via command line (ie. telnet owa.testserver.com 143). You should see a “* OK Microsoft Exchange Server 2003 IMAP4rev1 server…” reply . Just make sure you are testing this from outside your network.
  • Make sure your webaddress, username and password and tapped correctly. The iPhone is notorious for mistyping extra long passwords.

Final Thoughts:
I hope this How-to is a good starter for your IT people to get you started on the IMAP4 syncing on the iPhone. I have used it at my workplace many a times to answer emails and no one can tell you are replying via an iPhone. Please leave comments or suggestions if there are any typographic errors or anything I missed

Thanks for reading,
Wilson >__<


  1. 1 HighTechDad31 Aug 2007

    Beautiful write up! Thanks for the documentation! I will definitely put this on my del.icio.us list.

  2. 2 Jeff L04 Sep 2007

    Does this setup solve the problem of Exchange not deleting email that are deleted on the device?

  3. 3 Wilson04 Sep 2007

    Hi Jeff-

    Yes the problem still exists. I think it’s caused by the iPhone not having the proper permissions to delete the emails. The emails do get noted as read though if you read it on the iPhone and refer back to it on the eXchange server

  4. 4 rumdumpling06 Sep 2007

    Thanks for the write-up.

    I’ve found that if there is already an existing IMAP or SMTP virtual server on the Exchange server and you want to create secondary virtual servers to handle the iPhone traffic, a second NIC with a static IP will be most helpful. I’ve never really found virtual IPs bound to a single NIC to be very reliable.

    Also, Exchange not deleting emails is caused by the iPhone not sending the expunge command. It doesn’t have anything to do with permissions.

    A friend of mine wrote a .net app that runs on a PC that can be scripted to run a predetermined intervals.

    http://blogs.freshlogicstudios.com/Posts/View.aspx?Id=44a01293-3b32-4ee0-b23c-fac99348e1cd

    The other option is to configure the iPhone to send an expunge command. The downside is that the smallest increment that the iPhone will send an expunge command is 24 hours.

  5. 5 rumdumpling06 Sep 2007

    Sorry, I meant to post the instructions on how to configure the iPhone to send the Expunge command:

    Tap Settings > Mail, select the IMAP/Exchange account, tap Advanced, then select the purge interval from the “Deleted Messages” group.

  6. 6 Wilson07 Sep 2007

    rumdumpling-

    Thanks for the reply. You are right. This is not a bug, but simply a limitation on the iPhone. I hope with the next firmware update expected sometime this month, I hope this is addressed. It’s also good to have a .NET script run to make this happen if it is a big issue to users (it hasn’t become one yet in my office). Thanks!!

  7. 7 Jose Biton12 Sep 2007

    Wilson,
    Thanks for the write up. We have tried pretty much everything and are still having problems setting up my iPhone. Incoming emails work find and outgoing works fine on Edge. The problem is sending emails on Wifi networks. When I hit ’send’ the email appears to go out (the sending bar appears and progresses). The message even shows up in my ‘Sent’ folder on both the iPhone and the computer. But, I have the phone set to cc me on all emails and I never receive the test messages.

    We are using the following settings on the phone:

    Incoming
    - http://www.ourdomain.com
    - SSL ON

    Outgoing
    - smtp.ourdomain.com:465
    - SSL ON
    - Authentication NTLM

    Any thoughts?

    Thanks,
    Jose

  8. 8 Wilson13 Sep 2007

    Hi Jose-

    When you are connectng to Wifi, where exactly are you connecting from? Are you connecting from inside your Corp firewall wifi or somewhere else?

    Do you happen to hear the “whoosh” sound when the email sends out when you are on Wifi?

    Have you tried other Wifi networks like one at home? If your computer sees the sent email from the iPhone, then the email probably went out.. but did you ever receive it at the destination?

    How about sending an email to yourself on the iPhone? Like a text message via email… (Cingular: phonenumber@cingularme.com )

    Let me know what happens,
    Thanks
    W

  9. 9 Winston17 Sep 2007

    Jose - Have you considered the fact the WIFI network’s you’re connecting to don’t allow relaying of SMTP traffic from another domain? Not sure if that could be the issue. Many of the large ISP’s don’t allow, say joe@joesdomain.com to send mail on their (e.g. ATT, Comcast) network.

    Wilson, what do you think about the anti-relaying issue?

    My iPhone, using Exchange 2003, has it’s outgoing mail server set to cwmx.com (ATT mail server).

    Thanks.

  10. 10 Wilson17 Sep 2007

    Winston may have a point there about anti-relaying issues.

    AT&T may be blocking your emails from going out your Wifi Network if you are using your ISP’s MX server to send out.

    In my corporation, we have a valid MX record with our domain to the web. We do not go through our ISP to send out since we have the MX record in place.

    On the flipside, I could imagine there would be trouble with ISPs getting flooded with spam emails from end users. (hence, there is email solutions like Yahoo!’s web email for example) that allows authenticatation before sending out. To avoid this, I use my Yahoo email and send out through it. It works on WIFI and Edge without a problem. I also forward my domain specific emails to Yahoo and can reply back from a legit source.

    Another thing to ask is whether your ISP has given you static or dynamic IP addresses.. With static ones, you can at least create your own MX records and be a little more legitimate in the eyes of the BIG ISPs when receiving emails..

    Hope this helps you

  11. 11 Jin18 Sep 2007

    Wilson,

    Thanks for the write-up! My iphone can receive emails, but can’t send emails. The error message says, “Connection to the outgoing mail server my hostname failed. Please check the settings and try again” I’m using the default virtual SMTP and IMAP server in the protocols. Do I have to create a second virtual server as you suggested?

    Thanks!!

  12. 12 Wilson18 Sep 2007

    Hey Jin-

    Where are you having this problem at Jin? Over Wifi or EDGE or both?

    If you are on WIFI and you are within your own corp network where you can receive emails, then I would take a stab at looking whether you are allowing SMTP authentication to take place when you are sending emails out.

    Also, it could be DNS as well, so instead of using the NS name, try the IP address of the outgoing server. You would want to use the external IP address of your Exchange server for it.

    You do not need to create a secondary virtual SMTP server unless you want to only allow this virtual SMTP server to send out for mobile users only (probably not a good idea)

    Hope that answers your question.. lmk you that doesn’t and I’ll see what I can do.

    /Wilson

  13. 13 Matt19 Sep 2007

    Thanks in advance for your help.

    I have Exchange server 2003 with NO SERVICE PACKS. Client does not want to pay to have them installed. My question is “is SP2 absolutely necessary?” I can telnet to the server on all necessary ports and get the appropriate responses. I was wondering is SP2 is needed?

    Thanks,

    MAtt

  14. 14 Wilson19 Sep 2007

    Hey Matt-

    That’s a good question. The only way I can see SP2 as being a problem is the configuration of the SMTP servers. I think Exchange 2003 menus have not changed, so you should not run into any problems with or without SP2.

    The only thing that does come good with SP2 is the increased limit of the information store to 75gb from a mesly 10gb by default, and the integration of ActiveSync. Until the Iphone has ActiveSync features (which will be never) you should be alright without having the SP2 pack..

    This upgrade is “free” from M$ but you’ll probably need someone to do the update (and that maybe a problem for your client).

    Hope that helps,
    Wilson

  15. 15 jonny chan25 Sep 2007

    hi wilson,

    i can reply to mail (which send out ok) but cant send new fresh mail. get the outgoing…server..failed. any thoughts?

  16. 16 Wilson28 Sep 2007

    Hey Jonny-
    That’s very odd you can reply to new emails, but can’t send out. Seems like you are getting mixed with sending out with your POP3 SMTP account?

    Let me know what you find out, and maybe I can help with you more

  17. 17 George05 Oct 2007

    Wilson
    I have an Exhange 2003 SP2 setup just like you wanted above, however I am not able to send mail through my outgoing SMTP from the edge network. I have tried several combinations of settings but I still receive a user ID and or password is not correct I was able setup Outlook Express just fine with sending mail ,howerver I get cannot send anything through my server. I currrently am using Cingulars SMTP

    And detailed settings on the IPhone config and SMTP on the Echange Server

  18. 18 Boringplanet08 Oct 2007

    Wilson -

    Great write up. I finally got the mail working, but it will only work if i turn off the SSL feature. I have checked my firewall and i am pretty sure that it is set up correctly. I have the lisening/incoming port of 993 open and allowing traffic and redirects it to our internal exchange server.

    Is there something that i am missing in order to get this feature to work? We do have an SSL cert and we currently use it for our OWA where it works fine.

    I’m a little confused and refuse to give up trying.

    Any input would be greatly appreciated.

    Thanks,

    Boringplanet

  19. 19 Wilson13 Oct 2007

    @BoringPlanet - Seems like on Exchange you are not listening to port 993. Make sure that you can do a “telnet exchange_ip_addresses 993″ on a command prompt and get a response back. You may of forgot to start the IMAP4 service in services.

    @George - Hmmm. Make sure in the iPhone Exchange settings that you are sending it through SMTP and that your port is open. Most likely your firewall on the exchange side is blocking it.

    From an outside IP address source, try to “telnet exchange_external_ip_address 25″ into it. IF you don’t get a response back, most likely your firewall is blocking it.

    LMK if that helps or not

  20. 20 Boringplanet15 Oct 2007

    Thanks! I’ll give it a try.

  21. 21 mr.e-man15 Oct 2007

    @George - I’ve had “situations” with particular ISP’s that require you use their SMTP server to send mail through. They will not allow you to connect to another SMTP server. This may be the case with AT&T’s EDGE service. If so, it’s not that big of a deal. You can still send through their SMTP and have the message tagged with your email address. Please let us know what you find out. I’m just about to put this scenario in to production and I’d like a head’s up if at all possible.

  22. 22 Wilson15 Oct 2007

    @Mr.e-man

    I dont’ think using EDGE requires any ISP authentication other than the SIM card being activated and the EDGE service enabled.

    Sometimes the best way to solve these problems of not being able to send out emails is to delete the account on the iPhone and set it up again. I had this problem happen to me with my Exchange account not syncing. After deleting it and recreating it on the iPhone, it resolved itself.

  23. 23 Wilson19 Oct 2007

    I just realized one big thing I probably forgot to mention in the Original Post. This happened today at work when I was setting up my co-workers iPhone. He can receive emails, but could not send them out through Exchange? WTF?

    He had inadvertingly put the email address in the Exchange profile on the iPhone to his gmail address.

    This is a big NO NO and mainly the reason why he couldn’t send out emails from his Exchange account. As the From address is not the same as the SMTP servers outgoing domain is, (ie. You can’t send an email with a from address as AOL from a Yahoo account).

    I totally spaced about this fact. I just assumed that you will be setting up an exchange with the same from address

    So I ended up changing it to our email domain and it sent out just fine!

    Hope this helps anyone with this problem. Chime if it does :)

  24. 24 mr.e-man23 Oct 2007

    I wrote a lengthy post this morning, but forgot the CAPTCHA so I think it got lost. Rats! Let me try to summarize …

    I got an iPhone - yippie! I have a question regarding SEND functionality with Exchange (shocking, I know). I’ve setup iTunes to sync all of my email accounts to my iPhone. I have 3 ISP accounts and one Exchange account. On my Macbook Pro, the Exchange account works fine - bothing sending and receiving while connected inside or outside of our corporate network. On the iPhone, my Exchange account will only receive. I cannot send from inside or outside of our corporate network. I took a look at the Exchange mail account settings on the iPhone - they look OK. I even tried your recommendation of deleting the synced Exchange account on the iPhone and setting it back up manually. No luck! I noticed on the iPhone that the SMTP is setup to use port 587. I haven’t seen this port number in your documentation, or any other documentation I’ve found on the web. Do you know what this is? Also, my SMTP is setup to use SSL and NTLM authentication. We have an Active Directory environment. I am the IT Manager. Please let me know if there’s anything else you suggest I check in order to get this sending issue resolved.

    Thanks.

  25. 25 mr.e-man23 Oct 2007

    Well, a quick update. Seems I spoke too soon in regard to being able to send from my Macbook Pro when outside of our corporate network. I’m at home now and I cannot send messages from my Exchange account. Maybe this is a firewall issue, but then I don’t understand why the Macbook will send while in the office but the iPhone will not (presumably with the same settings).

    Any help is appreciated. Thanks.

  26. 26 Wilson24 Oct 2007

    @mr.e-man:

    Sorry for the late response, i been busy with things

    So what firmware version are you using?

    In my exchange environment, I am using a self assigned SSL cert. Are you using SSL in yours?
    I never seen SMTP port of 587, you can manually type in the port that’s going out as well, with a colon followed by port number.

    My outgoing SMTP settings are: SSL on, Authentication NTLM, server port 25.

    In the outgoing Mail server setting, under username, did you forget to add your domain?

    Did you make sure that your outgoing email address is the same as your domain? Sometimes your outgoing SMTP server might bark when it thinks you are a open relay to another domain.

    One thing I noticed is that your web address might be wrong to begin with. Can you get to WebOutlook from anywhere outside (like at starbucks) with the server address you put in? Seems that this can be the root of the problem altogether.

    I would suggest from the outside to do a telnet test and make sure you can telnet to the port that you opened up on the firewall. That should be the first test before anything…

    LMK
    Wilson

  27. 27 jason24 Oct 2007

    Do you have to have sp2 for exchange 2003 installed for this to work properly? I don’t and it seems to work fine in outlook express with imap4 and SSL, but not on the iphone.

    Thanks

    Jason

  28. 28 jason24 Oct 2007

    Do you have to have sp2 for exchange 2003 installed for this to work properly? I do not and it works fine in outlook express, but not on the iphone.

    Jason

  29. 29 Wilson24 Oct 2007

    @jason

    I do not think you need SP2 installed, but it just happened that the environment I was running needed SP2 because of the 16gb lmiitation that was in Exchange 2003 pre SP2. With the SP2 patch, it gives you up to 75gb in your information store…

    What exactly doesn’t work? Receiving from or sending from the iPhone? Can you be more specific?

    /Wilson

  30. 30 Andy Yeung25 Oct 2007

    I have trouble sending as well. Eventually, I have to use the carrier smtp to solve this issue. We have webmail running fine. I enter

    Both incoming and outgoing servers have SSL enable, 993 in this case.

    For incoming (this part works fine),
    webmail.mycompany.com
    mycompany\user
    password

    For outgoing (this is the problem),
    webmail.mycompany.com
    mycompany\user
    password

    Do I need to use webmail.mycompany.com:25 and disable SSL? I try it and it still gives me trouble. telnet to webmail.mycompany.com 25 and it responds. Do I need to allow relay in this case?

    Thx,

  31. 31 mr.e-man25 Oct 2007

    I think I’ve pretty much nailed my problem down to our firewall. Turns out that we have specified SMTP traffic to only a handful of IP’s running back to an email filtering service we use. I can telnet port 25 internally, but when outside the network (ie - home, etc.) I cannot get to port 25.

    OWA is running fine, but that’s all over SSL on port 443. Yes, we do have an SSL cert for our webmail address. I am also using SSL on, NTLM auth, and enter my username as username@domain

    Hope to be tweaking out the firewall once I get a few things squared away with this email filtering mumbo-jumbo. Will post back with progress.

    Thanks.

  32. 32 MarkM29 Oct 2007

    I have IMAPs syncing working fine with Exchange 2007 and iPhone with 1.1.1 but deletion of emails from iPhone still do not update on the server. The message moves to Deleted Items but no expunge. I know 1.1.1 was suppose to fix it but does anyone have this fixed expunge working with Exchange 2007?

  33. 33 Gus Anderson20 Dec 2007

    anyone have experience with the same except Exchange 2007? We have successfully set up IMAP4 and are receiving email as well as seeing all of the Exchange folders - Inbox, Sent, Deleted, etc….

    But not able to SMTP out - any ideas or tutorials on Exchange 2007 with the Iphone?

    Thanks

  1. 1 TechDadBlog » Blog Archive » iPhone: Firmware 1.1.1 - Delete Messages from Exchange Server, Calendar Invites and incompatible Vircom ModusMail
  2. 2 Vitamins Nutrition Supplements
  3. 3 iPhone: Nag the IT guy to get it to work. at gotshoo?
  4. 4 My Ghillie » How to setup IMAP4 Exchange 2003 email to sync with your iPhone at Monkeykit’s Blog