IMAP and SMTP over HTTP Proxy

The solution that I’m using for allowing Thunderbird (and if you really want, Kmail) to connect to my employer IMAP and SMTP servers, is not straightforward but it simply works…

For this to work you really need an external server where you can connect through ssh. This ssh server must be able to contact and connect to the required mail server, namely accessing their IMAP and SMTP ports.

Right now, I use a Linux VPS, located somewhere in the world ( 🙂 ) that I’ve bought through the lowendbox.com site. Great price per year (around 2€ per month).

I run ssh on this server on a non standard port.

The trick is simple:

Just open up two terminal sessions, and if you have ssh through corkscrew tunnelling working (see my previous posts: https://primalcortex.wordpress.com/2014/02/19/ssh-over-http-proxy/ ), it’s simple as executing this:

On terminal 1 and for IMAP (secure):

ssh -L 1993:imap.server.com:993 -p 12345 mysshserver

where imap.server.com is the name or external IP of the IMAP server and 993 is the secure IMAP port. The 1993 is the port at the local address 127.0.0.1 that is listening to connections from thunderbird. The -p 12345 is the port that my remote ssh server is running on and listening on for connections, and of course, mysshserver is the dns or ip address for the ssh server.

On terminal 2 and for secure SMTP:

ssh -L 1465:smtp.server.com:465 -p 12345 mysshserver.

When this two connections are established, then the local machine ports 1993 and 1465 connect through ssh and corkscrew tunnelling to the mail server… and thunderbird can now work as it should.

Just use as IMAP server the localhost and port 1993, and as SMTP server the localhost and 1465 port.

Of course for thunderbird to work, first is needed to create the tunnels.

Kmail and duplicated messages..

I’m using KMail to connect to my Corporate Exchange server using the IMAP protocol. So far so good, but after fiddling a bit with KMail I started to have a lot of duplicated messages on my IMAP folders. Pretty annoying…

I’ve found out that this is a long standing bug http://bugs.kde.org/show_bug.cgi?id=118074 and it’s related with spam filtering.

So the solution? Well goto Settings->Configure Filters and select the Bogofilter Advanced tab. Remove the check box on the option “Apply this filter to incoming messages”

If you want do it to all filters and enable one by one to see which one is the culprit…

At least in my configuration, the ClamAv filter does not produce the problem.

Also because my mail gateway based on Ubuntu LTS with Spamassassing is already doing spam filtering I can leave bogofilter off without any problem…

Update: Any filter that is on produces the issue, including ClamAV…