In some places internet access is provided via proxy. Some proxies block imap and smtp and allow only ports 80 and 443. If your email client doesn’t have proxy configuration (like my beloved Mutt), then you need to forward imap and smtp by hand. If the proxy you are behind supports https this means you can bypass it via https connect method.

To demonstrate that I’ll install Proxytunnel on my Ubuntu 14.04. After that I am creating 2 upstart scripts that launch proxy-tunnel daemons from proxy to imap/smtp (in this example to gmail’s servers). The daemons are started on system’s boot and are listening for imap connections on localhost:993 and smtp on localhost:993. For simplicity I’m adding my mail servers to hosts file, without that I would need to reconfigure my mail client to use localhost instead of *

sudo apt-get install proxytunnel
sudo touch /etc/init/tunnel-imap.conf /etc/init/tunnel-smtp.conf
sudo chmod 644 /etc/init/tunnel-imap.conf /etc/init/tunnel-smtp.conf


# proxy daemon for Gmail

description     "proxy daemon for Gmail imap"

start on runlevel [2345]

expect fork
respawn limit 10 5

exec    /usr/bin/proxytunnel -p -d -a 993


# proxy daemon for Gmail

description     "proxy daemon for Gmail smtp"

start on runlevel [2345]

expect fork
respawn limit 10 5

exec    /usr/bin/proxytunnel -p -d -a 587

add to /etc/hosts:


Tip 1: if you are an Upstart guru, you can make 1 upstart script instead of 2 🙂
Tip 2: one can use iptables instead of hosts

# iptables -t nat -A OUTPUT -d -j DNAT --to-destination

Tip 3: there is a Python script that does the same job (didn’t test it)

Another fix for

From June 1, 2013 stopped working for me. Again! The messages on my Onkyo were about country, in PC client “Sorry, the playlist service is not responding. Please try again later.”, “Starting radio failed. Unknown error.”, “Sorry, this track isn’t in the catalog, and thus cannot be streamed.”

A notice for users who use free proxies: you should use proxies with disabled X-Forwarded-For header. For those who use squid3 on their own server: to access you should add this line to squid3 config:


forwarded_for delete

Don’t forget to reload/restart squid:

sudo service squid3 reload