Page 1 of 1

iPhone IMAPS through Firewall

Posted: 20 Sep 2010, 06:52
by IDW
I've set up a Bibba/2 with a couple of test email accounts. The Bubba/2 is connected as a normal server on the LAN (not as a router/gateway or firewall), The LAN is connected to the Internet using a Cisco router. I've configured the Cisco to do port-forwarding for IMAP and IMAPS (IMAP over SSL).

I can access the mailboxes using several IMAPS clients - including a Windows-7 netbook and an HTC Android phone, but I can't get an iPhone 3G to connect at all. The error message from the iPhone isn't very helpful.

The iPhone email account settings are

Code: Select all

Advanced -> Incoming Settings -> 
    Use SSL: on, 
    Authentication: Password, 
    IMAP path prefix: / 
    Server Port: 993
The error message is
Cannot Get Mail
The connection to the server 'myserver' failed
Where 'myserver' is the static external ip-address of my Cisco router - which forwards connections on it's port 993 to the Bubba/2 port 993

Has anyone succeeded or got any tips for configuring an iPhone for IMAP over SSL for use with a Bubba/2?

Re: iPhone IMAPS through Firewall

Posted: 21 Sep 2010, 05:33
by RandomUsername
I can't see that you've done anything wrong there. My 3GS connects to my B2 with exactly the same settings. The only difference in my setup is that my B2 is running as the firewall and router too.

Are you sure it's not the outgoing connections that are failing on your iPhone? I have to use O2's own SMTP server because all other port 25 traffic is blocked.

Re: iPhone IMAPS through Firewall

Posted: 21 Sep 2010, 09:46
by IDW
@RandomUsername - thanks, I tried setting up outgoing mail for smtp.o2.co.uk - it validated the username and password OK.

However When opening the iPhone inbox for this IMAP account I still get the error message and it specifically gives the IP-address for my Bubba Two (actually the static IP-address my ISP allocated to my broadband connection - my router uses port-forwarding to route incoming IMAP & IMAP-over-SSL connections to my Bubba Two)

Looks like there's something odd about the way the iPhone tries to use IMAP. The Bubba logs aren't too helpful

A successful connection from an Android phone shows in the Bubba's mail log as

Code: Select all

Sep 21 13:57:32 bubba dovecot: imap-login: Login: user=<myname>, method=PLAIN, rip=99.123.129.67, lip=192.168.99.16, TLS
Sep 21 13:57:33 bubba dovecot: IMAP(myname): Connection closed
A failed iPhone connection shows in the Bubba's mail log as

Code: Select all

Sep 21 13:33:15 bubba dovecot: imap-login: Disconnected: rip=99.123.139.164, lip=192.168.99.16, TLS
I can't see any more detailed logging anywhere - can I turn up the Dovecot logging level somehow to see exactly where the authentication or connection is failing?

Re: iPhone IMAPS through Firewall

Posted: 21 Sep 2010, 10:55
by RandomUsername
I found the following lines in /etc/dovecot/dovecot.conf that might be of use:

Code: Select all

# Show protocol level SSL errors.
#verbose_ssl = no

# More verbose logging. Useful for figuring out why authentication isn't
# working.
#auth_verbose = no

# Even more verbose logging for debugging purposes. Shows for example SQL
# queries.
#auth_debug = no
remove the # and change "no" to "yes". You might need to restart dovecot:

Code: Select all

 /etc/init.d/dovecot restart
Just shooting into the air here; my iPhone initially complained about my Bubba's security certificate not being signed or something (Firefox does the same when you connect to the web interface over SSL), is it possible that you're encountering some kind of SSL error? Have you tried connecting over non-SSL - I know it's not a long term solution but it might help eliminate a line of inquiry.

Re: iPhone IMAPS through Firewall

Posted: 21 Sep 2010, 13:20
by IDW
@RandomUsername - thanks.

I did turn up the verbosity levels in dovecot as you suggested, restarting dovecot. Nothing extra seemed to show up in the logs (I grepped /var/log/* for imap and dovecot and looked at the tail of several)

Anyway, I also deleted and re-entered the username and password in the iPhone account and changed and re-entered some other settings - no joy.

Finally I deleted the whole account on the iPhone and recreated it. This worked! :D

Many thanks to you for the tips, support, general helpfulness and for the encouragement I got from knowing you had got it working.

Re: iPhone IMAPS through Firewall

Posted: 21 Sep 2010, 13:55
by RandomUsername
Glad you got it working even though I don't understand how or why it worked :S