11.09-Email Vacation Command
Description: FreeBSD Installer Guide
Keywords: FreeBSD, freebsd, FBSD, fbsd, Installer Guide, how-to, book, manual, guide, installing, configuring, aide step by step, instructions, from scratch, Unix

# FreeBSD Stable Release 6.0 Installer Guide

______________________________________________________________________

# Email Vacation Auto Responder

FBSD has a vacation command that is built into the FBSD system. It comes enabled as part of the base FBSD system. Vacation auto replies a canned message to the sender of a just received email message telling them that you are currently on vacation and not reading your mail. The vacation command really has nothing to do with being on vacation. It uses the standard mail forwarding facility to get control every time an email is received for the user, and if this is the first message it has received from that sender it sends a reply message back to the sender. Your can have the canned reply message say anything you want. This auto reply function can be used for many other reasons than telling the sender you are on vacation.

See the ‘man vacation’ page for details.

The vacation command is inserted into the control statement of the standard .forward file of the users home directory. A .vacation.msg file contains the content of the auto reply email message. The .vacation.db file controls the issuing of one vacation auto reply per unique sender email address per reply interval. In FBSD, the normal user account will not show the .files in the home directory.

To see them use the ll command.

# How The Vacation Process Works

When your MTA (sendmail or postfix) goes to put email in your mailbox it checks your home directory for a .forward file. It finds the forward command with vacation in it and executes the vacation program. No auto reply will be sent for any emails that have their "From:" header containing "???-REQUEST", "???-RELAY", "???-OWNER", "OWNER-???", "Postmaster", "UUCP", "MAILER", or "MAILER-DAEMON"' or if "Precedence: bulk" or "Precedence: junk" line is included in the mail headers. All these values are case insensitive.

Vacation then reads the emails "To:" and "Cc:" headers looking for a match to the login value it was passed or the -a values. On a match the .vacation.db file is searched to see if the sender email address has already been sent a reply. On a match no reply is sent. On a not found, the sender's email address is added to the .vacation.db file database and the auto reply message is sent.

# .vacation.msg File

Vacation expects a .vacation.msg file in your home directory containing the message to be sent back to the sender. You have to create this file by hand. The content of this reply message does not have to be vacation related. It must be an entire email message (including headers). For example:

From: bob@fbsdjones.com
Subject: Auto Responder
I am on vacation until July 22 2005.
If you have something very, very urgent, email
my Boss at king@fbsdjones.com.

# .vacation.db File

Vacation expects a .vacation.db file in your home directory. You use vacation -i from the FBSD command line of the logged in user to activate the vacation facility.

vacation –i This will create the .vacation.db file and post today's date as the start of the default 7 day auto reply interval.

vacation -i -r 14 would set the duration interval to 14 days, starting today, after the interval has expired the auto reply will stop.

vacation -i -r 0 will auto reply indefinitely, IE: has no interval trigger to stop the vacation auto reply function. The .vacation.db file can grow until it consumes all your free space on your hard drive, so issue vacation -i -r 0 once a week or monthly using a cron job to clear out and reset this file.

vacation -l will list the contents of the .vacation.db showing you a summary of who and when auto reply sent your .vacation.msg out.

# .forward File

Vacation expects a .forward file in your home directory. You must create this file by hand. The control statement in this file complies with the syntax of your MTA (sendmail, postfix). The normal coding of the control statement is like this:

\eric, "|/usr/bin/vacation eric"

The \eric, "|/path/program " is standard MTA .forward syntax.

The "/usr/bin/vacation eric" part points to the location where vacation lives and eric is the value being passed to the vacation program.

The user would replace both occurrences of eric in the above command with their login account ID.

# SYNTAX of the Vacation Command

vacation [-a alias] [-d] [-i] [-l] [-r interval] [-s address] login

-a alias Handle messages for alias in the same manner as those received for the user's login name.

-d Send error/debug messages to stdout instead of syslog. Otherwise fatal errors, such as calling vacation with incorrect arguments or with non-existent logins, are logged in the system log file using syslog(8). This should only be used on the command line, not in your .forward file. All syntax errors are displayed on the root console screen no matter who the user is that is using the .forward file containing the vacation command.

-i Initialize the vacation database files. It should be used before you modify your .forward file. This should only be used on the command line, not in your .forward file.

-l List the content of the vacation database file including the address and the associated time of the auto-response to that address. This should only be used on the command line, not in your .forward file.

-r interval Set the reply interval to interval days. The default is one week, 7 days from the day you use the –i option on the .vacation.db file. An interval of ``0'' or ``infinite'' (actually, any non-numeric character) will auto reply indefinitely. The -r option should only be done when the vacation database is initialized (see -i above).

-s address Use address instead of the incoming message sender address on the From line as the recipient for the vacation message.

login Mandatory field in the vacation command of the .forward control statement. This tells vacation who the user is. These must be the last characters before the double quotes that end the control statement. All - options must come before the login value. This value must be the users login account name.

# Procedure to Activate

The user who wants to active the vacation responder logs into his FBSD account. In this example that would be user bob. Then bob has to manually create two files, the .forward and the .vacation.msg files.

Create the .vacation.msg file and make it look something like the following:

ee /root/.vacation.msg

From: bob@fbsdjones.com
Subject: Auto Responder
I am on vacation until July 22 2005.
If you have something very, very urgent, email
my Boss at

king@fbsdjones.com.

Now create the .forward file:

ee /root/.forward

\bob, "|/usr/bin/vacation bob"

If the 7 days default life time for the auto responder to function is ok then you are done. If you need a longer period, then issue the vacation command to set a longer period like this for an auto reply interval of 14 days

vacation -i -r 14

During the auto reply interval you can disable it by commenting out the vacation statement in the .forward file.

______________________________________________________________________

This FreeBSD Installer Guide is an public domain HOW-TO. This content may be reproduced, in any form or by any means, and used by all without permission in writing from the author.