Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Mail app breaks with IMAP: Unable to connect, The server cannot contacted on port 993

Mail app has stopped working with all IMAP email accounts on multiple OS X machines, all running 10.9.4. This appears to be a longstanding Mail and/or authentication and/or keychain bug. This affects Apple iCloud email, Google gmail, Comcast, OS X Server email. Mail says that all IMAP accounts are offline with the triangle-! error that says upon a click, "Unable to connect, … The server imap.gmail.com cannot contacted on port 993". Substitute gmail and port 143 for any/all other IMAP account.

All these email accounts are online and accessible ON THE SAME COMPUTER without any issues using other mail clients such as Microsoft Outlook or webmail. And a port scan of the servers shows that port 993/143 are all open. This is only a problem with the Mail app, and I see the exact same problem on a Mac Mini server and a completely different MacBook Pro on completely different networks.

Has anyone figured out a way to reset Mail to factory settings and fix this issue without doing a fresh install of the OS?

I've done all the obvious and not-so-obvious troubleshooting:

Delete and reenter email accounts

Fix Permissions

PRAM reset

Safe reboot and Shift-login

Power cycle router

sudo killall -HUP mDNSResponder

Keychain Access>Delete all email authentication entries

Tried online fixes suggested:


http://apple.stackexchange.com/questions/68702/the-server-returned-the-error-the -server-imap-gmail-com-cannot-be-contacted-o

Nothing fixes Maill app's problems. I'm also on tier 2 support from AppleCare on a new box that has a fresh install of Mavericks with the same problem—the tech couldn't figure out the issue from screen sharing sessions or the EDC logs and has suggest ANOTHER fresh install of Mavericks.


At this point I'm ready to give up, declare the Mail app to be broken, and replace it with Postbox.


Has anyone been able to fix Mail app after it breaks on IMAP accounts?

Mac mini, OS X Mavericks (10.9), Server, 16 GB, EyeTV+Turbo.264 HD

Posted on Jul 28, 2014 3:55 AM

Reply
14 replies

Jul 28, 2014 12:29 PM in response to essandess

Triple-click the word "telnet" in the line below on this page to select the whole line:

telnet imap.gmail.com 993

Copy the selected text to the Clipboard by pressing the key combination command-C.

Launch the built-in Terminal application in any of the following ways:

☞ Enter the first few letters of its name into a Spotlight search. Select it in the results (it should be at the top.)

☞ In the Finder, select Go Utilities from the menu bar, or press the key combination shift-command-U. The application is in the folder that opens.

☞ Open LaunchPad. Click Utilities, then Terminal in the icon grid.

Paste into the Terminal window by pressing command-V. I've tested these instructions only with the Safari web browser. If you use another browser, you may have to press the return key after pasting.

You should almost instantly get three lines of output below what you entered, the last of which is this:

Escape character is '^]'.


If there's no output within ten seconds, consider that a failure. If you get something different from the above, please post it in a reply. You can then quit Terminal.

Jul 28, 2014 2:10 PM in response to Linc Davis

Except for the Mail app, port 993 is open and working to all email clients, telnet, mmap, etc.:


$ telnet imap.gmail.com 993

Trying 74.125.142.109...

Connected to gmail-imap.l.google.com.

Escape character is '^]'.

Connection closed by foreign host.

$ nmap -p 993 -Pn imap.gmail.com


Starting Nmap 6.40 ( http://nmap.org ) at 2014-07-28 17:06 EDT

Nmap scan report for imap.gmail.com (74.125.142.109)

Host is up (0.061s latency).

Other addresses for imap.gmail.com (not scanned): 74.125.142.108

rDNS record for 74.125.142.109: ie-in-f109.1e100.net

PORT STATE SERVICE

993/tcp open imaps


Nmap done: 1 IP address (1 host up) scanned in 3.20 seconds


I suspect that Mail app can hit 993 too, but that there's a system-level authentication failure related to Keychain, and that Mail app is misdiagnosing or misreporting the problem in its error message.

Jul 28, 2014 3:24 PM in response to Linc Davis

Thank you very much for your responses, Linc.


Yes, I've verified the very same behavior with brand new test accounts on two independent 10.9.4 boxes on two independent networks.


I've also tried setting the router DNS on my LAN to Google's 8.8.8.8.


I'm having Macports install wireshark right now—I'm curious what Mail app's TLS exchange with the IMAP server looks like.

Jul 28, 2014 3:44 PM in response to essandess

There's a known bug in Mail that causes it to fail to connect to any server after the system wakes from sleep until relaunched, when certain DNS servers or routers are in use. The details aren't known, at least to me. What you're describing seems to be worse than that. I doubt that network analysis is going to help. You would have to file a bug report with Apple. Then maybe the bug will be fixed in a few years.

Jul 28, 2014 4:22 PM in response to Linc Davis

P.S. To clarify, I've verified this issue in safe mode on new user accounts independently.


And wireshark shows that Mail app isn't sending any packets out on port 993. Mail app isn't even talking with imap.gmail.com.


Here's what a packet capture looks like (tcp.port == 993 or ip.addr == 74.125.142.109) with Mail app launched with "Take all accounts online" and with Connection doctor:

User uploaded file


In contrast, here's what the telnet session looks like:

User uploaded file

Jul 28, 2014 4:56 PM in response to Linc Davis

Apple have already suggested a reinstall, but one of the boxes had a fresh install 7 weeks ago, so I'm not confident that this would fix this problem for long. This is a server, and I simply don't have the time resources to go through another fresh install, so I'll just use a different mail client.


What I don't understand is why I cannot simply bring the Maill app back to a fresh install status by deleting specific plists, Mail directories, or whatnot.

Jul 29, 2014 3:12 AM in response to essandess

I purchased Postbox and it's up and running smoothly with all my IMAP accounts. It's basically a nice version of Thunderbird with Notification integration, but no Keychain access, so you have to use their password vault and manage your own SMIME certificates. Better than Outlook, but a working Mail app would be the best option, if that existed. I plan to try a fresh install sometime after 10.10.3 is rolled out.

Sep 6, 2014 10:01 AM in response to Linc Davis

Good news -- Apple Enterprise support helped me to fix this problem.


I was experiencing TLS authentication problems with many apps and servers. Mail.app would fail for all accounts, iCloud Keychain stopped working, as did Adobe Updater and EyeTV program updates and more. I was unable to fix the problem and was tentatively blaming some unidentified OS X TLS bug. Apple Enterprise support helped uncover a problem with the /etc/hosts file created by net.hphosts.hosts.plist-- the hosts list from hosts-file.net/download/hosts.zip contains numerous nonconforming domain names (specifically, names that begin with a hyphen).


By copying /etc/hosts.orig back to /etc/hosts, then shutdown then safe boot and login, then shutdown, then normal boot, all my TLS problems vanished and everything began working again, Mail.app included. There are several known fragility issues with OS X and /etc/hosts, and this apparently is another one.


I updated the script in net.hphosts.hosts.plist to use the perl module Data::Validate::Domain to only add valid domain names to /etc/hosts. All applications have been working fine ever since.

Mail app breaks with IMAP: Unable to connect, The server cannot contacted on port 993

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.