An E-mail from the North Pole

Caution! May contain 25th December spoiler!

Christmas is really about kids (and my wife judging from previous years’ excitement), so last year I setup an auto-responder e-mail, which was made known to some friends with three children (see blog entry dated 5th December). Simply put, mail sent to santa@ this domain (not fully listed to avoid spammers hitting an auto-responder) will get the following response:


Thank-you for sending your request to me. I hope that I will be able to bring you everything you would like. Don’t forget though, that you only get presents if you’ve been good!!!

If you change your mind, then please e-mail me again and I will remember not to bring it on Christmas Eve.

See you end of the month!



=== Santa Claus = The North Pole ===

There’s nothing complex about this – it’s a simple auto-responder based on an “out-of-office” script, but with the contents changed to suit mails to Santa. Once Christmas Eve arrives, the message changes to the following:


Thank-you for sending your request to me. I hope that I will be able to bring you everything you would like, but it’s now getting very late and I’m already starting to load up the sleigh for Monday night.

You have a good Christmas and I’ll try not to wake you as I’m passing.




=== Santa Claus = The North Pole ===

That entertained all three last year, but unfortunately the eldest has since deduced that Santa isn’t quite what he originally seemed. Two grateful e-mails later though and all are happy.

If you’re wondering why they haven’t guessed who is really originating the e-mails, then the “” part was suggested to be because I sorted-out the internet on Santa’s computer. Seems logical really.

The Techy Stuff

I don’t know if anyone cares about this, but you may hit on this page after searching for a few keywords in Google, so I thought I’d let-in on the secret (not about Santa though – I’ll let someone else spoil that for you).

My current setup is a Linux machine with two local regular users. (Almost) all mail for my domain is delivered to a single POP box in my webhost, which is then collected by fetchmail running periodically on a crontab. fetchmail delivers to my local MTA (postfix) in what the fetchmail manual terms “multi-drop mode”. There are allsorts of disclaimers scattered about the manuals about it not working very well, but I’ve never had any problems.

Once the mail is on the machine, then postfix then uses a regular expression table to decide which one of us (or both) receive the e-mail, based on the original To: field. That all works fine and dandy, but the default setup is for postfix to use maildir delivery and the auto-responder requires a bit more functionality than a simple folder-drop.

I didn’t want to fire off a new process for every mail delivered, whether to santa or not, so the postfix mailbox_command global setting was not an option – instead use a map which determines which user should have which delivery process in place. In my case I wanted procmail to do the mail manipulation. All that was needed now was a way to get procmail to respond appropriately and we’re done.

Here’s the detailed steps to re-create it (this assumes you’re using exactly the same setup as above – you may need to tweak):

Create a new local user “santa”

Create ~santa/.signature:

=== Santa Claus = The North Pole ===

Create ~santa/.procmailrc (based on the standed procmail example vacation script)

# set domain to keep this rc file generic, DOMAIN is used in the
# X-Loop header to prevent mail loops, among other things.
DOMAIN= yeah, whatever
# path to file containing generic reply message to be sent back.
# by default, the contents of the user's ~/.signature file will be
# appended to the REPLYFILE message.
# path to file where seen e-mails are logged
# should clear out this file when disabling vacation services
# generic path for finding programs; one must contain formail(1)
# Where to base operations out of, e.g. where the vacation.lock file
# gets written to, etc.
# Prevent anyone else using this
# will grow unbounded unless other scripts trim it down
# Writes and sends the reply message, checking the cache before
# sending
:0 Whc:
* !^X-Loop: ${LOGNAME}@${DOMAIN}
| formail -rD 8192 ${CACHEFILE}
:0 ehc # if the name was not in the cache
| (formail -rI"Precedence: junk"
-A"X-Loop: ${LOGNAME}@${DOMAIN}" ;
cat ${REPLYFILE} ;
echo "";
cat ${HOME}/.signature
) | $SENDMAIL -oi -t
# Forward mail onto the local user ian
! ian

Cretate the auto-response message ~santa/autoresp.msg:

Thank-you for sending your request to me. ...

Insert the mailbox_command_maps option into /etc/postfix/

mailbox_command_maps = hash:/etc/postfix/mailbox_commands

Create the /etc/postfix/mailbox_commands file:

santa /usr/bin/procmail -d ${USER}

Create the hash map file:

[root@katy postfix]# postmap mailbox_commands

Add an entry for santa into the regexp map /etc/postfix/virtual.regexp:

/^ santa

Reload postfix

[root@katy postfix]# service postfix reload
Reloading postfix:                              [ OK ]

That should be everything sorted. Don’t forget to check you have broken anything and that it works as expected.