Arnt Gulbrandsen
About meAbout this blog

Using procmail as an autoresponder

Procmail is old and almost forgotten, but still works well. This short script is the autoresponder for jøran@blåbærsyltetøy­.gulbrandsen.priv.no:

:0 c
/tmp/jøranmail

:0
* !^FROM_DAEMON
* !^X-Loop:
* !^Auto-Submitted:
| (formail -r -t -I"From: Jøran Øygårdvær " -A"Auto-Submitted: auto-replied" -A"Mime-Version: 1.0" -A"Content-Type: text/plain; charset=utf8" -A"Content-Transfer-Encoding: 8bit" ; echo "Liker du blåbærsyltetøy? Jeg synes blåbærsyltetøy er veldig godt." ; echo ; echo "-- " ; echo "Jøran") | /usr/sbin/sendmail -t

The first clause stores all incoming mail in /tmp/jøranmail just in case it's needed for debugging. The second clause filters out three kinds of mail that should not receive an autoreply. For messages that pass all three hurdles, it runs formail with many arguments to create an EAI-compliant autoreply header, echo to write a brief reply, and sends the result back.

It may not be terribly readable, but it's brief and reliable. That glass is two thirds full, not one third empty.