qmail

remote auth patch

A lot of people are using qmail at home on their private computers as mailserver and as mailrelay. But many mail servers on the internet reject emails from dynamic public ip addresses because the providers of those mail servers believe that home made mail relays are a source for spam letters and so on. If you want to write an email to a friend of yours which MX host is such a mail server and if you are using qmail at home behind your dialup line, your mail won't get delivered. Instead qmail will bounce it after a few days (you could check /var/qmail/queue/mess/* before that period). To avoid this, you have to tell qmail that it should relay mails to your friend's MX host using another mail relay, eg. your ISP's mail relay. So you have to setup /var/qmail/control/smtproutes something like this:

your-friends-domain.tld:your.isp-mail-relay.tld
But usually you have to authenticate yourself before using your ISP's mail relay. qmail does not provide any remote authentication, so I wrote this patch.
After applying my patch and recompiling qmail, you can setup another control file /var/qmail/control/remoteauth (be sure that it is not world-readable!):
your.isp-mail-relay.tld:your.mailaddress@isp.tld:PLAIN base64 encoded
string
So, whenever your qmail server relays or delivers an email via your.isp-mail-relay.tld, it will use your.mailadress@isp.tld as the envelope sender's address and authenticate by plain using that base64 encoded string.
Base64 encoded strings for plain smtp authentication are constructed by concating twice your username and password, each seperated by NULL:
username\0username\0\password
You can use two perl scripts I wrote for encoding and decoding base64 strings, base64.pl and ubase64.pl:
$ echo -e 'username\0username\0\password' | base64.pl

download

qmail-1.03.remoteauth.diff