[Exim] Autoreplies

Top Page
Delete this message
Reply to this message
Author: Martijn Grendelman
Date:  
To: exim-users
Subject: [Exim] Autoreplies
Hi,

I am trying to set up an autoreply / vacation-like system using MySQL. The
system should:
1) get reply subject and text from a MySQL database
2) reply only to 'personal' mail, to speak in Exim-filter terms
3) reply to the same sender once a week maximum

First I had a router check if the user has the autoreply option turned on
(through a MySQL query) and have a a transport set up all the data for the
reply message (text and subject again through a MySQL query). I guess that
with the 'once' and 'once_repeat' options for the autoreply transport, I
can accomplish (3) although I haven't tested this yet. Can I use a
systemwide 'once' database, something like /var/spool/exim/autoreply.db?

As for (2), I couldn't figure out how to do that with the above setup, so
I tried using a filter file. The autoreply router now looks like this:

mysql_autorespond:
  driver = redirect
  condition = ${if eq{} {${lookup mysql{SELECT autoreply FROM auth WHERE
autoreply='yes' \
         AND username='$local_part' AND domain='$domain'}}}{no}{yes}}
  allow_filter
  hide_child_in_errmsg
  ignore_eacces
  ignore_enotdir
  reply_transport = mysql_autoreply
  no_verify
  no_expn
  file = /etc/mail/autoreply.filter
  unseen


The autoreply.filter file checks for 'personal' and uses 'once' and 'once
repeat'. But now, I can't seem to get the reply subject and message text
from the database. It's unclear to me which string expansions work in
filter files and which don't.

The filter file contains this line:

text ${lookup mysql{SELECT artext FROM auth WHERE
username='$local_part' AND domain='$domain'}{$value}

When testing the filter with 'exim -bf', I get:

Filter error: unknown filtering command "mysql{SELECT" near line 7 of
filter file

So, I would like to know:
- can I use query style lookups in filter files and if so, how?
OR
- is there a way to check for 'personal' mail when not using a filter
file? Something along the lines of:

condition = ${{if match {$h_from}{$local_part@$domain}} and {if
...}}{1}{0}}

or something simpler?

Thanks,
Martijn.