Tuesday, January 16, 2007

Vacation message using procmail

This blog moved to a new location, please visit us at http://ramble.m2m.at.

If you use procmail to filter messages, you can use it also to setup a vacation email response:
  1. Create a file called vacation.txt and fill it with your "vacation message".
  2. Create a file called vacation.rc fill it with the following commands (and don't forget to adjust the values for USER, DOMAIN, and PATHxxx to your needs):
:0 Whc: vacation.lock
* .*for <USER@DOMAIN>
* !^FROM_DAEMON
* !^X-Loop: USER@DOMAIN
| formail -rD 8192 vacation.cache
:0 ehc
| (formail -rA"Precedence: junk (autoreply)" \
-A"X-Loop: USER@DOMAIN" ; \
cat PATHTOVACATIONMESSAGE/vacation.txt \
) | PATHTOSENDMAIL/sendmail -oi -t
  1. Find your .procmailrc file and add the following line after your filter commands (again adjust the PATH):
#INCLUDERC=PATHTORCFILE/vacation.rc
If you receive now an email at USER@DOMAIN and it is not filtered out by your spam filter, the vacation commands are activated. It checks if the email is for you, does not originate from a mailing list, and is not been processed before. It also creates a file called vacation.cache, where it stores the email addresses to which a vacation message has already been sent, in order to do not send such a message again (don't forget to delete it when you deactivate the vacation filter). At last it replies with the message stored in vacation.txt.
The "Precedence: junk (autoreply)" helps to avoid bouncing messages from other MTAs.

No comments: