Exim Vacation messages

Posted by Fred C (W6BSD) on Dec 21 2011

I don't really understand why people love so mush auto-responders, especially business people. These messages add a considerable amount of useless noise in our mailboxes. Even though I dislike those emails, it doesn't prevent companies or friends I am hosting on my servers to request them.

One of those companies is closing during the holidays. They wanted to have a vacation message sent whenever someone tried to contact them during this period.

They wanted to have a single vacation message for the entire company instead of asking each employee to set his or her own vacation message for each account.

Here is the solution I have used to do this.

Router

virtual_vacation:
  domains = +virt_domains
  driver = accept
  require_files = /space/hosting/${domain}/vacation.msg
  transport = virtual_vacation_trans
  condition =  ${if or { \
                {match {$h_precedence:} {(?i)junk|bulk|list}} \
                {eq {$sender_address} {}} \
                } {no} {yes}}
  # do not reply to errors or bounces or lists
  senders = ! ^.*[email protected]*: ! ^bounce-.*@.*: ! ^.*[email protected]*: ! ^owner-.*@.*:\
            ! ^[email protected]*: ! ^[email protected]*: ! ^[email protected]*:\
            ! ^[email protected]*: ! ^[email protected]*: ! ^[email protected]*
  unseen
  no_verify

The router checks if the file message.msg exists in the home for that domain. The router also tries to determine if the mail is coming from a mailing list or if it was auto-generatd. We don't want to send the vacation message to these addresses.

Transport

virtual_vacation_trans:
  driver = autoreply
  to = ${sender_address}
  from = "[email protected]${domain}"
  file = /space/hosting/${domain}/vacation.msg
  once = /var/tmp/vacation_${domain}.db
  once_repeat = 7d
  subject = "Re: Away for holidays / En vacances - ${local_part}@${domain}"

The transport is pretty straightforward. It sets the to, from, and subject as well as the content of the mail extracted from the file vacation.msg. The email addresses of the senders are kept into the file vacation${domain}.db, in order to send the vacation message only once a week. Determined by once_repeat = 7d.


 Exim      Mail