A procmail based autoreply/autoresponder/vacation script
There is a number of programs available which allow users to set up automatic mail replies. One of the oldest is vacation. procmail even features some recipes in the procmailex manpages. Anyway, autoreply_deferentially.rc tries to be more cautious and to reply (hopefully) only to directly addressed, personal messages.
Please note that autoreply software is essentially tricky and can cause a lot of trouble. Many administrators, discourage the use of such software. Here are some discussions of pros and cons:
The following shows the core part of the script (slightly simplified). For the full code including more comments, variables' settings and defaults, download autoreply_deferentially.rc.
# --- send autoreply to senders (in case you received a _personal_ message) :0 * AR_AUTOREPLY ?? yes * $!^X-Loop: $AR_MYADDRESS { :0 Whc: autoreply_deferentially.lock # Check to see if the mail was addressed to us * $^(To|CC): (.*\<)?$AR_MYADDRESS # Don't reply to daemons and mailinglists and junk * !^FROM_DAEMON * !(^List|mail(ing|(ing)?[- _]?list)|-l@|newsletter) * !^Precedence: (list|junk|bulk) * !^(From|Reply-To): .*noreply # Never reply to ourselves * $!^From: .*$AR_MYADDRESS # Miscellaneous criteria * !^From: .*((www|web)-?(data|master|admin)|robot@) # RFC 3834 suggests to accept only "Auto-Submitted: no" * !^Auto-Submitted: ... # Don't reply to receipts (delivery notifications, out of office, ...) # Get a filter list e.g. from http://wox.at/as/_/regex_mail_receipts ###* !? grep -Ef /etc/procmailrc_receipts ### uncomment if available # Do not reply to some selected addresses (local blacklist) * !^From: .*(@example.com|wf-batch@brz\.gv\.at) # Make sure the autoreply text exists * ? test -r $AR_MSGFILE # Mail loops are evil | $AR_FORMAIL -rtD 65532 "$AR_VACATION_CACHE" :0 ec # if the senders address was not in the cache { # Get address to send reply to and write a line to $AR_LOGFILE :0 * ^From:.*\/(<?[a-zA-Z0-9_][-a-zA-Z0-9_+.=]*@[-a-zA-Z0-9_+.=]+\.[-a-zA-Z0-9_+.=]+[a-zA-Z0-9_]>?) { # Logging the sent autoreplies AR_NOW=`date +%Y-%m-%d\ %H:%M` AR_LOGFILEBAK="$LOGFILE" LOGFILE="$AR_LOGFILE" LOG="$MATCH $AR_NOW$AR_NL" LOGFILE="$AR_LOGFILEBAK" } # Write a message to the default procmail log LOG=" >>> sending autoreply to $MATCH $AR_NL" # Send autoreply message :0 h | ($AR_FORMAIL -rtA"Precedence: junk" -A"Auto-Submitted: auto-replied" \ -A"X-Loop: $AR_MYADDRESS" -A"From: $AR_FROMADDRESS" \ -A"$AR_EXTRAHEADERS" ;\ cat $AR_MSGFILE \ ) | $AR_SENDMAIL -i -t } }
I hope it is sufficiently obvious that this should not be used at all unless one at least roughly understands what the procmail recipes are doing. Anyway, please, download the full code and look at the comments for further instructions. Don't forget to provide the file in $AR_MSGFILE and to remove $AR_VACATION_CACHE if an old version exists.
Use at your own risk! Tested only on Debian 4, 5 & 6.
disclaimer & imprint :: copyright :: backlinks :: page history :: index :: recent changes (all) :: go to top ::