betabug... Sascha Welter

home english | home deutsch | Site Map | Sascha | Kontakt | Pro | Weblog | Wiki

16 July 2008

Shell fun: take a vacation(1)

Nobody likes mail auto-responders, but...

Nobody likes auto-reply messages, but sometimes - and when used correctly - the Unix vacation(1) utility can be useful. There are a few steps to set it up. I'm taking this on my OpenBSD machine, other flavors of Unix might vary...

The first step in our "used correctly" plan is to use the official vacation program for our "auto-away" messages, not just some dumb auto-reply script. vacation is clever enough to keep a log of who it has informed of you being away (thus avoiding mail loops) and it know to avoid replying to mailing lists and bulk mails. All this is in contrast to some other such solutions, it's incredible what kind of dumb stuff appears till this day, when the well behaving Unix programs have been around so long.

Not only is vacation much safer and cleverer than other auto-reply scripts, it's also ultimately more geeky - and thus rewarding!

Initialize vacation

You need to initialize the vacation program for your account. Simply type:

vacation -i

while being logged in as your normal user (the account you want to use vacation for. This will generate the database ~/.vacation.db for your account.

sendmail restricted shell setup

If - like on OpenBSD - your sendmail is using the "sendmail restricted shell", you will have to enable the use of the vacation program with sendmail. This happens by adding a soft link to the vacation executable to a special directory. Sendmail will only execute programs that have links there. This setup has to be done only once, then it will work for all users. As root do:

# ln -s `which vacation` /usr/libexec/sm.bin/vacation

(Of course with the correct location of that directory, consult your docs if in doubt.)


The file ~/.vacation.msg contains the full message that will be delivered to recipients. man vacation gives a nice example. If you're not used to type mail messages with full headers, take a good look and mind to include the blank line between the headers and the message body. It could look something like this:

From: (Fred Unixuser)
Subject: I am on vacation
Delivered-By-The-Graces-Of: The Vacation program
Precedence: bulk

I am on vacation from last year till next year.
I'll get your mail with subject
but I will be *very* slow to react.

Fred Unixuser

vacation will include the senders subject wherever you type $SUBJECT.


To enable all of this vacation mail reply sending, you could be using a simple .forward file in your home directory. It would contain something like this:

\loginname, "|/usr/libexec/sm.bin/vacation -a alias1 -a aka1 loginname"

Here you have:

  1. the login name of your account, with a backslash in front, so you actually get a copy of the incoming mail message
  2. in quotes the command to pipe the message to vacation
  3. with one or multiple -a parameters, you can tell vacation to also reply to mails with those "aliases" somewhere in the recipient headers.
  4. the last argument to vacation is again the login name of your account

Give it a try!

With all this set up, you can try sending mail to your account. For the first mail you send there, you should get an auto-reply. Further mails shouldn't get auto-replies (until - in the default setting - one week has passed). Don't forget to switch it off when you're back... wait... you're coming back from that vacation, right? I can't do all the job myself!

Posted by betabug at 15:28 | Comments (0) | Trackbacks (0)
ch athens
Life in Athens (Greece) for a foreigner from the other side of the mountains. And with an interest in digital life and the feeling of change in a big city. Multilingual English - German - Greek.
Main blog page
Recent Entries
Best of
Some of the most sought after posts, judging from access logs and search engine queries.

Apple & Macintosh:
Security & Privacy:
Misc technical:
Athens for tourists and visitors:
Life in general:
<< darcs roxx | Main | On board >>
There are no comments.
You can trackback to:
There are no trackbacks.