Normally, when a mail server tries to deliver an email, it will connect to the destination mail server directly. e.g.
Draft an email to email@example.com on my PC ---> my mail server ---> yahoo's mail server
But as mentioned above, my ISP blocks all the access (port 25) to the outside world. So there is no way for my mail server to connect to other mail servers and deliver the emails.
Luckily, by the SMTP standard, I could force the mails route through my ISP's mail server:
Draft an email to firstname.lastname@example.org on my PC ---> my mail server ---> Netvigator's mail server ---> yahoo's mail server
So far so good. The remaining problem is: the Netvigator's SMTP server requires authentication which my mail server (Qmail) doesn't support! Thanks to open source, it is easy to patch the code though.
- First, go get the patch
- Apply the patch to qmail-remote.c
patch < qmail-remote-auth.patch
In my case (on FreeBSD), one of the chunks can't be patched. But don't worry, just open the source to patch it manually!!
- The patched source needs a base64 function (the authentication for SMTP is in base64 format). Go get it here. Unpack the file and copy base64.c and base64.h to the qmail source folder. Compile it.
gcc -c base64.c
- Build the new binary
Replace the existing qmail-remote (usually under /var/qmail/bin) with the patched version
- Now, the Qmail SMTP routing file (/var/qmail/control/smtproutes) supports username and password. e.g. To route everything from my mail server to Netvigator's SMTP server:
:smtp.netvigator.com username password