Once upon a time, friends would complain to me about random problems they had. Well, actually, they still do. But that’s not relevant to this discussion. Anyway, this particular problem involved moving between different networks and having to reconfigure his mail client to use a different SMTP server all the time. So I thought, “Gee, there should be a relatively simple way to work around this.” At the time, I had been working on an unrelated proxy server project at work, so I thought a proxy server made sense here too. And so, smtpproxy was born.

The concept is simple, though there are a few limitations. At present, they are:

  1. All the different networks to which you connect have different IP address ranges (i.e., they have different network addresses).
  2. None of the SMTP servers you use require authentication or encryption.

The first constraint isn’t too bad, but the second one could be a problem. At some point I’ll probably add auth and SSL support, though I really don’t know when I’ll get to it.

The code is rather old, and not all that portable. I wrote it in 2003 or so. I know it works on Linux, and on Mac OS X (or at least it did back then). It may not work on anything else. I’m not accepting patches, because it’s something of a mess, and needs to be mostly rewritten. It isn’t even autotooled, so you may need to mess around with the Makefile.

The config file is relatively simple, and you can use ~/.smtpproxyrc or /etc/smtpproxy.conf. Each line should have first a network address (in dotted quad notation), and then a server hostname, separated by a space, e.g.:


There are two ways of running smtpproxy: as a normal user, on a non-privileged (> 1024) port, or setuid root. I’d suggest running as a normal user, though smtpproxy should be safe running setuid, as it drops root privileges right after binding to the port. If you run it setuid root and someone hacks your system, don’t blame me (though if you want to let me know, that would be nice). Type smtpproxy --help for a list of command line options.

Assuming you get it running, just point your mail client’s outgoing mail server at localhost, and set the port appropriately if you aren’t using the default (privileged) port of 25.

And without further ado, you can grab it from my Subversion repository:

1svn co smtpproxy

If the server is down, it just probably means my machine locked up because with the composite extension is unstable. Oh well.