I'm using procmail to receive email messages and then forward them on to a script for handling. Sometimes this will even mean generating an email (for example, forwarding the message to another user, or answering a query).
Needless to say, I have zero interest in loading up my server with emails from autoresponders or vacation responses, so I'm wondering if there is an easy way to filter out these messages. I am piping these to a script anyway, so I can always roll my own filter in the script, but I'd rather not reinvent the wheel.
I already know I should trash messages with Precedence: junk
or Precedence: bulk
. Can I just filter them like you would any other header in procmail?
Reading the docs would be a good start. There's a mini-howto here which covers the basics. Automatically generated messages should be picked up by the FROM_DAEMON and FROM_MAILER rules. Also use X-Loop (described in doc referenced above) to avoid looping messages.
Finally, you can suppress repeat replies to the same address as demonstrated here (for the pruposes of a vacation auto-responder). So even if the remote system does not play nicely and populate the from address properly and strips out the X-Loop header, you can break the cycle.
Procmail can be used to create very sophisticated systems - it's a programming language in its own right. You might also want to have a look at:
Update
Since www.clarconnect.com has dropped off the internet, I fetched the content from the way back machine:
Overview
I know not everybody approves of e-mailed vacation auto-replies, but the fact is that some of our clients/users insist on it. So here is a way you can set up a system where the users can administer their own vacation auto-reply messages.
Features of this procmail vacation auto-reply recipe:
Before you proceed any further you will need to have procmail enabled on your system. For instructions, go to the following howto: Filtering E-mail With Procmail
Take special note of the section titled "Enable Procmail in Postfix".
Configuring Vacation Auto-Reply
To enable vacation auto-reply for your users you will need to create a .procmailrc file in the /home/"username" folder for every user requiring this service. The file will need to contain the code below.
Once you have created the file, make sure that you change the following lines:
Now you will want to make sure that the .procmailrc file has the following security permissions:
User and Group should be set to the username of the email user you're setting it up for.
File Permissions should be set to rwx------ for the user only (i.e. 0700).
** Warning! **
Note that if you set the permissions for .procmailrc to the wrong user or set the permissions so that user,group and others can read/write/execute .procmailrc, then procmail will ignore your .procmailrc file.
Once these settings are configured the auto-reply should work. If you experience problems with the auto-reply, you can uncomment the following two lines and check the content of /tmp/procmailvacation.log.
Using Vacation Auto-Reply
Now that the recipe is installed users can turn on the vacation auto-reply by sending themselves an email with the following subject:
The body of this email will become the auto-reply email message. The user will receive the email the user just sent to themselves with the following text appended to the end:
To turn off the vacation auto-reply the users send themselves an email with the subject
The user will receive the email the user just sent to themselves with the following text appended to the end:
Well, if the subject contains a standard response, then you can filter everything with "Out Of Office" (or similar) to
/dev/null
.