A Patch to add CRAM-MD5, PLAIN and LOGIN authentication to serialmail

Since I have a dialup connection I recently started to use serialmail, which works in conjunction with qmail.

Usually I don't send my mail via the mail relay from my ISP but via mail.gmx.de. This relay has support for CRAM-MD5 authentication.

So first I patched serialmail to support CRAM-MD5 authentication. I updated this patch and now it adds support for CRAM-MD5, PLAIN and LOGIN authentication.

Usage is very simple: Add a user and password to the command-line of serialsmtp and it will try to authenticate via one of the three authentication mechanisms. serialsmtp will parse the server response to the EHLO command and will use the first supported authentication mechanism in the following order: CRAM-MD5, PLAIN, LOGIN.

Since most people probably will use maildirsmtp to do this job, maildirsmtp will pass argument 5 and 6 as user and password to serialsmtp. So in my case I simply invoke:

   maildirsmtp /home/rohloff/pppout rohloff-ppp- mail.gmx.de \
   curin.highspeed myUserName myPassword

Updated: 06 Jan 2004. Added improvements from Petre Rodan. This fixes a bug which prevented the use of the LOGIN method. Serialmail will now try all available methods until one method succeeds, or there are no more valid methods. The order in which the different methods are tried is now: CRAM-MD5, LOGIN, PLAIN.

If you find this patch useful, you can download it.