How to set up iPhone 5 iOS 6 email with IMAP over SSL on a custom port?

Basically I have the same problem as this guy 5 years ago but the thread contained no useful answer. Maybe there are people out there who became smarter in the meantime? Please help me out how to get my iPhone read emails via IMAP over SSL on a custom port to the corporate server. The issue is that the iPhone only seems to work if you use the standard 993 port for IMAPS, not with a custom port as we have. I've installed the corporate root certificate in a profile, and it shows up as trusted and verified in the phone, so that should not be the issue. The mail app in the iPhone tries to connect, I can verify that from the server, but then does nothing, doesn't try to authenticate, doesn't log out, nothing is going on, and then drops the connection after 60 seconds. Repeats this every 5 minutes (as set to fetch e-mail every 5 minutes.)
Original thread 5 years ago: https://discussions.apple.com/message/8104869#8104869

Solved it by some (a lot) of fiddling.
Turns out it's not a bug in the iPhone, it's a feature.
Here's how to make it work.
DOVECOT
If the IMAPS port is anything other than 933 (the traditional IMAPS port) the iPhone's Mail App takes the "Use SSL" setting on the IMAP server as 'TLS', meaning it starts the communication in plain text and then issues (tries to issue) the STARTTLS command to switch the connection to encrypted. If, however, Dovecot is set up to start right away in encrypted mode, the two cannot talk to each other. For whatever reason neither the server nor the client realizes the connection is broken and only a timeout ends their misery.
More explanation about SSL/TLS in the Dovecot wiki: http://wiki2.dovecot.org/SSL
So to make this work, you have to set Dovecot the following way. (Fyi, I run Dovecot 2.0.19, versions 1.* have a somewhat different config parameters list.)
1. In the /etc/dovecot/conf.d/10-master.conf file make sure you specify the inet_listener imap and disable (set its port to 0) for imaps like this:
service imap-login {
  inet_listener imap {
    port = --your port # here--
  inet_listener imaps {
    port = 0
    ssl = yes
This of course enables unencrypted imap for all hackers of the universe so you quickly need to also do the things below.
2. In the /etc/dovecot/conf.d/10-ssl.conf file, make sure you set (uncomment) the following:
ssl = required
This sets Dovecot to only serve content to the client after a STARTTLS command was issued and the connection is already encrypted.
3. In /etc/dovecot/conf.d/10-auth.conf set
disable_plaintext_auth = yes
This prevents plain text password authentication before encryption (TLS) is turned on. If you have also set ssl=required as per step 2, that will prevent all other kinds of authentications too on an unencrypted connection.
When debugging this, please note that if you connect from localhost (the same machine the server runs on) disable_plaintext_auth=yes has no effect, as localhost is considered secure. You have to connect from a remote machine to make sure plain text authentication is disabled.
Don't forget service dovecot restart.
To test if your setup works as it's supposed to, issue the following (green) from a remote machine (not localhost) (I'm using Ubuntu, but telnet and openssl is available for almost all platforms) and make sure Dovecot responds with something like below (purple):
telnet your.host.name.here yourimapsportnumber
* OK [CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE STARTTLS LOGINDISABLED] Dovecot ready.
Most importantly, make sure you see 'STARTTLS' and 'LOGINDISABLED'. Then issue STARTTLS and hopefully you see something like this:
a STARTTLS
a OK Begin TLS negotiation now.
(The 'a' in front of STARTTLS is not a typo, a prefix is required by the IMAP server in front of all commands.)
Close the telnet (with 'a logout' or Ctrl+C) and you can use openssl to further investigate as you would otherwise; at the end of a lot of output including the certificate chain you should see a line similar to the one below:
openssl s_client -starttls imap -connect your.domain.name.here:yourimapsportnumber
. OK Pre-login capabilities listed, post-login capabilities have more.
You can then use the capability command to look for what authentication methods are available, if you see AUTH=PLAIN, you can then issue a login command (it's already under an encrypted connection), and if it's successful ("a OK Logged in"), then most likely your iPhone will be able to connect to Dovecot as well.
a capability
* CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE AUTH=PLAIN
a login username password
* CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE SORT SORT=DISPLAY THREAD=REFERENCES THREAD=REFS MULTIAPPEND UNSELECT CHILDREN NAMESPACE UIDPLUS LIST-EXTENDED I18NLEVEL=1 CONDSTORE QRESYNC ESEARCH ESORT SEARCHRES WITHIN CONTEXT=SEARCH LIST-STATUS
a OK Logged in
POSTFIX
Likewise, you have to set Postfix to wait for STARTTLS before encrypting the communication.
1. You have to delete the setting smtpd_tls_wrappermode=yes from /etc/postfix/master.cf and/or /etc/postfix/main.cf, if it was enabled. This will mean Outlook won't be able to connect any more because it requires a TSL connection without issuing STARTTLS as per Postfix documentation (haven't tested.) In my case we don't use Outlook so I didn't care. Outlook + iPhone + custom SMTPS port are simply not possible together at the same time as far as I understand. Pick one to sacrifice.
2. Require encrypted (TLS) mode for any data transfer in /etc/postfix/main.cf:
smtpd_tls_security_level = encrypt
3. Authentication should only happen while already in encrypted (TLS) mode, so set in /etc/postfix/main.cf:
smtpd_tls_auth_only = yes
Don't forget postfix reload.
To test if this works, issue the following telnet and wait for the server's greeting:
telnet your.host.name.here yoursmtpsportnumber
220 your.host.name ESMTP Postfix (Ubuntu)
Then type in the EHLO and make sure the list of options contains STARTTLS and does not include an AUTH line (that would mean unencrypted authentication is available):
ehlo your.host.name.here
250-STARTTLS
Then issue starttls and wait for the server's confirmation:
starttls
220 2.0.0 Ready to start TLS
Once again, it's time to use openssl for further testing, detailed info here http://qmail.jms1.net/test-auth.shtml
CERTIFICATES
You also need to be aware that iOS is somewhat particular when it comes to certificates. First of all, you have to make sure to set the following extensions on your root certificate (probably in the [ v3_ca ] section in your /etc/ssl/openssl.cnf, depending on your openssl setup), especially the 'critical' keyword:
basicConstraints = critical,CA:true
keyUsage = critical, cRLSign, keyCertSign
subjectKeyIdentifier=hash
authorityKeyIdentifier=keyid:always,issuer:always
And then on the certificate you sign for your mail server, set the following, probably in the [ usr_cert ] section of /etc/ssl/openssl.cnf:
basicConstraints=CA:FALSE
keyUsage = nonRepudiation, digitalSignature, keyEncipherment
subjectKeyIdentifier=hash
authorityKeyIdentifier=keyid,issuer
subjectAltName = DNS:your.domain.name.here
issuerAltName=issuer:copy
Please note, the above are results of extensive google-ing and trial and error, so maybe you can omit some of the stuff above and it still works. When it started working for me, I stopped experimenting because figuring this all out already took way too much time. The iPhone is horribly undocumented when it comes to details of its peculiar behaviors. If you experiment more and have more accurate information, please feel free to post here as a reply to this message.
You have to import your root certificate into your iPhone embedded in a profile via the iPhone Configuration Utility (free, but only available in Windows or a Mac; details here: http://nat.guyton.net/2012/01/20/adding-trusted-root-certificate-authorities-to- ios-ipad-iphone/ ), after having first added it to Windows' certificate store as a trusted root certificate. This way the Utility will sign your certificate for the phone and it becomes usable; if you just add it from the phone it will be there but won't be used. Using a profile has the added benefit of being able to configure mail settings in it too, and that saves a lot of time when you have to install, remove, reconfigure, install again, etc. a million times until it works.
Another undocumented constraint is that the key size is limited to a max of 4096. You can actually install a root certificate with a larger key, the iPhone Configuration Utility will do that for you without a word. The only suspicious thing is that on the confirmation screen shown on your iPhone when you install the profile you don't get the text "Root Certificate/ Installing the certificate will add it to the list of trusted certificates on your iPhone" in addition to your own custom prompt set up in the iPhone Configuration Utility. The missing additional text is your sign of trouble! - but how would know that before you saw it working once? In any case, if you force the big key certificate on the device, then when you open the Mail App, it opens up and then crashes immediately. Again, without a word. Supposedly Apple implemented this limit on the request of the US Government, read more here if you're interested: http://blogs.microsoft.co.il/blogs/kamtec1/archive/2012/10/13/limitation-of-appl e-devices-iphone-ipad-etc-on-rsa-key-size-bit.aspx .
IN CLOSING...
With all this, you can read and send email from your iPhone.
Don't forget to set all your other clients (Thunderbird, Claws, etc.) to also use STARTTLS instead of SSL, otherwise they won't be able to connect after the changes above.

Similar Messages

  • How to upgrade my iphone 4 ios 4.1 or above but not ios7.0

    how to upgrade my iphone 4 ios 4.1 or above but not ios7.0? . For watsapp sake , I wanna upgrade to ios 5 or above please give me some solution

    you can only upgrade to the most recent version, 7.1

  • How to unlock my iphone 4, ios 5.1. at

    How to unloch my iphone 4, ios 5.1. at&t without at&t account?

    http://www.att.com/esupport/article.jsp?sid=KB414532#fbid=Ont7guWFCdY

  • HT4623 how do you update iphone 3gs ios 2.1 to 4.3 please help

    How do i upgrade ios2.1 on how do you update iphone 3gs ios 2.1 to 4.3 please help my i phone to download sky go also i cannot connect to my sky wifi at home.is it true only 2 devices at a time laptop 1 and desktop 2 thank you

    If it is a 3GS you cannot update it to 4.3, you can only update it to iOS 6. Install the latest version of iTunes on your computer, connect the phone, click on its name on the left, then click the "Check for Updates" button on the right.
    If you can't connect to your home WiFi try rebooting the router.

  • How to upgrade my iPhone for iOS 4.0

    how to upgrade my iPhone for iOS 4.0

    If you have an iPhone 3g you can upgrade to iOS 4.2.1.  If you have a 3gs or later, you can upgrade to iOS 6 (only).  Connect your phone to the computer you normally sync with, and update from iTunes.
    The User Guide is available at http://support.apple.com/manuals/ or downloadable from iTunes as an iBook.

  • Does anyone know how to "find my iphone" without iOS or iCloud?

    Does anyone know how to "find my iphone" without iOS or iCloud? I downloaded the app, but am unable to locate it as I do not have icloud or iOS.

    you have made many question about how to find your iphone without icloud or didn't download the app "find my iphone",I‘m sorry to say,you can't find back you iphone unless the miracle happened,god bless you .你已经写了很多关于如何找到没有开启icloud服务,而且也没有应用“find my iphone"的IPHONE手机,那我很遗憾的告诉你,除非奇迹出现,否则是不可能的,上帝保佑你!
    BTW:my iphone also got lost yesterday。另外,我的IPHONE昨天也丢了……伤心……

  • How to downgrade my iphone 4s ios 6.1.3 to 6.1.2

    How can i downgrade iphone 4s ios 6.1.3 to 6.1.2

    downgrading is not supported. You would do better to resolve whatever the problem is that is causing your wish to downgrade.

  • HT3960 how to restore my iphone in ios in 4.1, because i update it in 4.2, now it stuck..

    how to restore my iphone in ios in 4.1, because i update it in 4.2, now it stuck..

    See Here...
    Unable to Update or Restore
    http://support.apple.com/kb/HT1808

  • HT4623 How to update my iPhone 5 ios 6 to ios 7?

    How to update my iPhone 5 ios 6 to ios 7?

    You can update over the air or via iTunes... Of course, you'll have to wait until it's actually released on Wednesday...

  • Hi, i hav an Iphone 4S (ios 7.1) with me.. it is abnormally increasing its temperature due to no reason and i am really worried about that. The fully charged phone is getting empty within minutes. Not able to attend the calls due to its overheating. help

    Hi, i hav an Iphone 4S (ios 7.1) with me.. it is abnormally increasing its temperature due to no reason and i am really worried about that. The fully charged phone is getting empty within minutes. Not able to attend the calls due to its overheating. help me please..
    It shows a 'temperature rise, need to cool down your phone' message regularly.. It happens when i when i try to connect my fone to the internet using cellular data, and it happens more suddenly when my 3g is on.. help me to sort out this, please

    Make an appointment with the Apple genius bar for an evaluation.

  • I have an iPhone 3gs (iOS 5.1) with BB 6.15 (the lastest) and it don't detect my SIM

    I have an iPhone 3gs (iOS 5.1) with BB 6.15 (the lastest) and it don't detect my SIM and I don't know what to do (I have unistalled all, and installed the lastest iTunes software)

    Maybe your iPhone was hacked/jailbroken to use another carrier?
    If so, now it locks back to the original carrier.

  • How to set background ChoiceBox item color to ChoiceBox with css?

    How to set background ChoiceBox item color to ChoiceBox with css?
    I need to change items list backgound color.
    I tried with following code, but it doesnt helps:
    .choice-box .context-menu {
      -fx-backgound-color: red;
    .choice-box .menu-item{
      -fx-background-color: red;

    In Java 8, either of your selectors should work.
    In Java 7 (JavaFX 2.2), you need the following workaround:
    #choice-box-menu-item {
         -fx-background-color: red ;

  • Previously i set up iphone 5 same user (account) with my brother.. Now i want to set up as my own User... but try to Erase all content n settings and plug in itunes to set up as a new iphone but it's keep sync with my brother phone ... help please ?

    previously i set up iphone 5 same user (account) with my brother.. Now i want to set up as my own User... but try to Erase all content n settings and plug in itunes to set up as a new iphone but it's keep sync with my brother phone ... help please ?

    I recommend that you
    Create a NEW account/ID for her using these instructions. Make sure you follow the instructions. Many do not and if you do not you will not get the None option. You must use an email address that you have not used with Apple before. Make sure you specify a birthdate that results in being at least 13 years old
      Creating an iTunes Store, App Store, iBookstore, and Mac App Store account without a credit card
    Use the new ID on her iPod but only for:
    Settings>Messages>Send and Receive
    Settings>FaceTime
    Settings>GameCenter
    and Settings>iCloud
    Continue to use the same/common Apple ID for Settings>iTunes and App stores so you can share purchases.

  • Dose anyone no how to fix my iphone it is not charging with my laptop

    hello do you no how to fix my iphone it is not charging with my laptop

    Important: Only original iPhone can be charged from a FireWire-based power source. If iPhone is connected to a computer that's turned off or is in sleep or standby mode, the battery may drain.
    Verify that the outlet being used is working.
    Try another USB power adapter if available.
    If no other USB power adapter is available, try connecting to a high-power USB 2.0 port (not a keyboard). The computer must be turned on and not in sleep or standby mode.
    Try another USB cable if available.

  • How to set attched file name while sending email through ABAP

    Hi All- tell me how to set attched file name while sending email through ABAP.
    regards...
    Abhay

    Sure,  when you are adding your entry to the packing list,  give the name in the obj_name field.
    *File 2
      mailbin = 'This is file 2'.
      append mailbin.
      data: start type i.
      data: end type i.
      start = tab_lines + 1.
      describe table mailbin lines end.
      mailpack-transf_bin = 'X'.
      mailpack-head_start = 1.
      mailpack-head_num = 1.
      mailpack-body_start = start.
      mailpack-body_num = end.
      mailpack-doc_type = 'TXT'.
      mailpack-obj_name = 'TEST2'.        "<-  RIGHT HERE
      mailpack-obj_descr = 'Subject'.
      mailpack-doc_size = tab_lines * 255.
      append mailpack.
    Regards,
    RIch Heilman

Maybe you are looking for

  • DUMP WHEN TESTING WEB PAGES

    Working on BBPCRM 3.1 having this dump when testing web pages. Page contains the typical start pages of SAP hello world and a simple button...                                                                                 Runtime Errors         TEXT

  • Trying to consolidate multiple custom date metrics in a simple summary view

    I'm working with leads and campaigns and trying to provide analysis of the inflow, processing and output of the leads associated with a campaign. (There is some out of the box analysis do this, but it's not what I'm looking for). The intent is to mea

  • Mapping 3 columns to 3 attributes in the same element

    Hi, I have 3 columns which are not in a collection as part of my result set. I need to map these 3 columns to an attribute in my result xsd in the transformer. eg on the left I have : addrline0, addrline1, addrline2. On the right I have an element ca

  • Is it possible to recreate (med & large format) negatives to standard size?

    I have a medium format negatives and large 6x7cm ideal format negative sizes. How can I recreate the negatives to 35mm standard negative size: 24mm x 36mm with the least compromise in quality? Thank you.

  • How to file a bug report?

    Hi there  I'm using a Sony Z3 Compact with Lollipop 5.1.1 and after the update, there is no longer any message on the lock screen, telling me the remaining charge time. I've read others saying the same thing, so I'm definately not alone. I'd like to