Installing and Using procmail as the LDA for sendmail under FreeBSD

procmail is a very handy tool for sorting, filtering and redirecting e-mail. Setting procmail up as the local delivery agent for sendmail under FreeBSD is very straightforward and allows the administrator (and users) much more flexibility in determining how mail gets delivered. Setting procmail as the LDA allows users to not worry about the $HOME/.forward file that's necessary if procmail is used stand-alone. Using procmail directly from sendmail instead of from $HOME/.forward saves a few steps, potentially having a positive performance impact.

If users don't wish to do any special handling and prefer the same behavior as regular mail.local, that's no problem. procmail will deliver to the same place mail.local will deliver to when there is no $HOME/.procmailrc file to process.

These instructions are broken in to two parts, installing procmail and changing sendmail's LDA, to keep things in order.

Installing procmail

  1. cvsup your ports tree to make sure you're getting the latest version of procmail.
  2. Install mail/procmail using the FreeBSD ports system. No fancy -D defines needed or anything, just fire and forget.

    cd /usr/ports/mail/procmail

    make install clean

    That's it. :)

Changing sendmail's LDA to procmail

  1. Back up your current sendmail config. Backups are handy when you accidentally bork the new config. :)

    cp -r /etc/mail /root/mail-backup/

    Or whatever. You get the idea.
  2. Add some lines to your site's file. This will probably be in /etc/mail. You'll need to add FEATURE(local_procmail) with the other FEATURE lines and MAILER(procmail) with the other MAILER lines (near the end of the file).
    You'll have to eyeball the location. On a side note, I toss define(`confSMTP_LOGIN_MSG',`')dnl in to my config to disable the banner display when an SMTP connection is made to the machine. Note the direction of the quotes.
  3. Rebuild the .cf file from the .mc file and restart sendmail. From inside /etc/mail:

    make all install restart

    will rebuild your site's from the, copy the to (what sendmail actually reads for configuration information) and restart sendmail.
  4. Make sure mail still works. :) Fire off a test e-mail from another machine to yourself after making sure you don't have a $HOME/.procmailrc or a $HOME/.forward kicking around. Once you've verified that mail is still getting where it should using procmail without any filters, try setting up some basic filters as outlined in some of the links provided below.

Mike Hogsett suggests a quick way to make sure procmail is handling local mail delivery is to create a simple $HOME/.procmailrc that only logs mail as it's delivered. Just add a line like:


to your $HOME/.procmailrc and start watching for $HOME/procmail.log. The first time you get an e-mail delivered to your mail spool, $HOME/procmail.log will be created and information about the e-mail will be recorded. Consecutive mail deliveries will append to $HOME/procmail.log. If everything is happening as it should you're in good shape.

What you do with procmail is completely up to you. I'm planning on installing SpamAssassin at a later date and suggesting to users that they filter their mail through SpamAssassin using procmail, but beyond that I'm not going to make anyone do anything.

Finding out more

If you're interested in doing neat things with procmail be sure to check out the following links.

Thanks goes to Steve Atwell and Jayson Anderson for confirming what I suspected about the sendmail config and procmail.

Page created 20030719 04:07.
Page modified 20040708 22:13.
Comments? Suggestions? Send them to
© 2003 Josh Tolbert. This page may not be duplicated without permission.