[plug] Vacation Messages using Postfix

Matt Kemner zombie at penguincare.com.au
Tue Oct 10 11:12:46 WST 2006


Hi Jonathan

On Mon, 9 Oct 2006, quoth Jonathan Young:

> (1) Add a vacation message for a particular user with Postfix and have
> the knowledge to control options relating to forwarding, auto-reply text
> and avoiding sending a reply to every email (multiple messages from one
> person for example).  I know this can be done, but have no idea how.
> Most of my previous mail servers have been Qmail.

The vacation(1) program you have seen earlier is designed to do exactly
that - it keeps a cache of addresses so it will not reply more than once
to each sender.  Vacation is MTA independent so it will work equally well
with postfix, sendmail, exim etc - probably even qmail, although qmail has
always been a bit of an odd duck :)

The man-page describes how it works.  You just create a
/home/username/.forward file that forwards to the vacation program, in
addition to sending a copy to the user's INBOX as per normal.
The outgoing message is by default kept in /home/username/.vacation.msg

I suggest you set up a "test" email address on that server first, and
experiment with the vacation program until you are satisfied with it.

> (3) Script or daemonise these changes so I can set and forget them at the
> start of the person's leave instead of writing myself a reminder to go
> back and undo it on their return.

This one's easy, and applies to anything you can run from the command
line - you use the at(1) command for this.

Create the .forward file as a file named ".forward-notactive" first

Then assuming for this example that they go on vacation at 5:30pm on the
13th of October and return 8:30am on the 30th you would run the following
two commands:

  live:~# at "17:30 13 Oct 2006"
  warning: commands will be executed using /bin/sh
  at> mv /home/username/.forward-notactive /home/username/.forward
  at> <EOT>
  job 39 at 2006-10-13 17:30
  live:~# at "8:30 30 Oct 2006"
  warning: commands will be executed using /bin/sh
  at> mv /home/username/.forward /home/username/.forward-notactive
  at> <EOT>
  job 40 at 2006-10-30 08:30

Hit Control-D (EOF) to signify you've finished entering commands
(this is where you will see the <EOT>)

As a side-note, if they return to work on a Monday it might even be
preferable to disable the "vacation" command at COB on the previous
Friday, since anyone emailing them on the weekend is not likely to expect
a reply until Monday anyway.

Once again, use your test email address combined with a pair of at jobs
that will run in the next few minutes to verify it does what you think it
will do.

You can use the atq(1) command to view current jobs in the "at queue" and
atrm(1) to remove jobs.

Let me know if the "vacation program" doesn't work out for you, and I'll
show you how to do the same thing with procmail(1) :)

I use procmail on servers running "virtual" mailboxes where each mailbox
does not have its own corresponding unix username, and therefore nowhere
to place a .forward file.

Kind Regards,

 - Matt Kemner             Perth:     Tel 08 9322 3444 Fax 08 9221 3444
  Penguin Care             Adelaide:  Tel 08 8311 1144 Fax 08 8311 1177
  Linux & VoIP Specialist  Melbourne: Tel 03 8648 6644 Fax 03 8648 6677
  Mobile: 04 2022 3444     Brisbane:  Tel 07 3337 9988 Fax 07 3337 9977




More information about the plug mailing list