Sendmail: The Fun, The Pain - Part I · 18 October 2007, 20:17

After a break of many years from writing custom sendmail rules, I had the opportunity to create some very interesting custom sendmail rules and to integrate a custom rule with our LDAP server (SunOne). After initially struggling to remember how sendmail address handling works, I had some fun.

Thank goodness for O’Reilly’s “Sendmail: The Definitive Guide” and “Sendmail Cookbook,” were it not for those books I would have spent a lot more time re-learning how text matching and replacement works with sendmail. It also took me quite a while to re-wrap my head around the sequence of parsing that sendmail does for From and To addresses. Finally, rule syntax had completely escaped me and I had to re-read parts of several chapters of both books to get back up to speed with them.

Once I spent a half a day catching up, however, I was able to implement some really interesting rules. At the client with this sendmail installation there are groups of testers that have to get mail, real users who get mail, and sysadmins who get admin messages.

The difficulty comes with the 3 development environments at this client and the testers and real users all in the same place. Rules:


After working pretty hard :p to get all of the custom rules working, I expected the worst from the LDAP integration but was very pleasantly surprised to find that it was well documented and writing a rule that tested against an LDAP store was really pretty easy, even with a custom LDAP search. Woot.

I also developed a small test framework to ensure that any time I make changes to my m4 sendmail configuration file I can regression test the rewriting rules to ensure that I have not broken anything. I will write about that script and post its’ contents in a future installation of this short series on sendmil.

Finally, I will also post some of the basic tenets of sendmail rules that I re-learned and some simple examples of writing custom rules that I hope will help others get started with sendmail rewriting.

— Max Schubert



SMTP AUTH debugging: nice HOW-TO · 17 August 2007, 07:08

Taken from:

This works on Redhat variants:

cd /etc/mail
make stop
/usr/sbin/sendmail -bD -X /tmp/test.log

— Max Schubert