Tip Cache
Your source for tech tips
Tip: How to avoid ISP blocks on port 25 (SMTP)
Posted By: apeiro
Some ISPs will block outgoing connections to port 25 (SMTP) in attempt to curb spam delivery. Nowadays, unprotected Windows machines can quickly become part of spam-delivering botnets, and blocking access to third-party SMTP servers can curtail this.
The easiest way around something like this is to relay through another server. The obvious limiting factor here is that you need control of another server that is not blocked from hitting tcp/25. You don't necessarily need root access, but you do need a shell.
Basically, what we do is run a TCP relay program on the server. It listens on a non-standard port (eg, tcp/2525 instead of tcp/25) to avoid being blocked by your ISP, then forwards all connections to the real mail server.
ASCII diagrams are worth 1000 words.
+---------+ +--------------+
| You |------tcp/2525-----> | Relay Server |
+---------+ +--------------+
|
tcp/25
+-------------+ |
| SMTP Server | <--------+
+-------------+
My favorite relay software is socat. It can do more than just relay TCP connections, but that's all we need it for.
To listen on port 2525 and relay all connections to smtpserver.com:25, just run this on the relay server:
$ socat TCP-LISTEN:2525,fork TCP:smtpserver.com:25 &
Now change your mail client's SMTP server from smtpserver.com:25 to relayserver.com:2525 and your connection will no longer be blocked.
