E-Mail:

Repelling the Invaders Part 4

Repelling the Invaders - Part 4

Procmail, you’ll remember, uses a combination of recipes and environment variables to filter, forward, or otherwise process your email. Most of these environment variables have reasonable defaults, but it’s important to understand what many of those variables are.

Variable Action
MAILDIR Current directory while procmail is executing
DEFAULT Default mailbox file
LOGFILE The name and path of the file that will contain actions taken and error messages
VERBOSE Allows the user to turn on extended diagnostics for debugging
LOGABSTRACT Forces procmail to write the ‘From’ and ‘Subject’ lines to the log file, as well as which folder the mail was finally sent to and how long the message was.
SENDMAIL The path to the sendmail program.

Now, let’s take a look at a ~/.procmailrc file that includes some of the environment variables as well as a useful recipe.

MAILDIR=/home/tony/mail
SENDMAIL=/usr/local/bin/sendmail

:0
* ^From:. foobarspam-lists
{
   EXITCODE = 67
   :0 h:
   bounce.log
}

According to Shell reader Sean:

Anything matched by this rule causes procmail to exit with error code 67,
and then to copy the headers (the ‘h’) of the message into the “bounce.log” file. The effect of the EXITCODE is that sendmail thinks that the user doesn’t exist, and sends out a bounce. Handy for getting
off of mailing lists, or from those companies that keep on sending after you’ve unsubscribed.

That’s a useful recipe.

Remember that the environment variables are part of the ~/.procmailrc file. Setting these variables in ~/.procmailrc determines the actions of the invoked instance of procmail and all the individual recipes that are contained therein. For a list of all the available environment variables and their defaults, see the procmailex(5) man page.

As we’ve already hinted, procmail may also rely on other system programs, including sendmail. Next week, we’ll look at the interaction of these programs and how one uses the other to help clean up your inbox.

What Do You Think?

 

Want to Start a Blog Here for Free?

Are you an expert in one subject or another? If your goal is to help others and dispense hard-earned information back to the community, stake a claim on your very own Lockergnome blog today! You can write about anything - no matter the topic. Sign-up to start blogging!

64 queries / 0.455 seconds.