How to i route Postfix through a socks proxy

email-serverpostfixroutingsockstraffic

I have a mail server that uses postfix to relay all the outbound mail through Gmail's smtp servers. Now I have another internet provider and this one is through a SOCKS proxy connection.

How can I setup my postfix server to route all its outbound mail traffic to the SOCKS proxy?

Best Answer

First off, what situation landed you in such an awkward internet connection scenario? I've seen a lot of messed up configurations, but requiring customers to tunnel all of their traffic to a remote ssh server is absurd. I must say, it sounds like you're perhaps trying to run a server somewhere where you aren't supposed to, or are trying to fly under the radar somehow.

Anyway, why don't you just make another non-dynamic ssh tunnel for the smtp traffic? Something like:

$ ssh user@host -L:2525:remote.smtp.server:25

Then you can have postfix deliver use localhost:2525 as its "smarthost".

This will be much more straightforward than using a dynamic proxy like you're currently trying to do.