Re: [exim] auto-reply with exceptions from SQL lookup

Top Page
Delete this message
Reply to this message
Author: Veres Imre
Date:  
To: tlyons
CC: exim-users
Subject: Re: [exim] auto-reply with exceptions from SQL lookup
On Mon, 9 May 2011 08:51:02 -0700
Todd Lyons <tlyons@???> wrote:

Hello Todd,

> > Routers section:
> > ----------------
> > virtual_vacation:
> >    driver = accept
> >    condition = ${if and{ \
> >                {!match {$h_precedence:}{(?i)junk|bulk|list}} \
> >                {eq {${lookup mysql{select users.on_vacation from users,domains \
> >                where localpart = '${quote_mysql:$local_part}' \
> >                and domain = '${quote_mysql:$domain}' \
> >                and users.on_vacation = '1' \
> >                and users.domain_id=domains.domain_id}}}{1}} \
>
> So you check if a particular user is in the database (a local user)
> and then you do send a vacation message if they are found. Off the
> cuff it seems like you're missing a not in front of that eq{}
> function.


Actually that condition is only for querying if the user set his/her autoreply function and I still think it is OK.
(If the "on_vacation" field equals 1, we have to handle autoreplies, otherwise we step to the next router.)

I'd like to catch those addresses after the condition, with "senders":

senders = !${lookup mysql{select vn.address from users u,domains d,noautoreply vn \
            where u.localpart = '${quote_mysql:$local_part}' \
            and d.domain = '${quote_mysql:$domain}' \
            and u.domain_id=d.domain_id \
            and vn.user_id = u.user_id}{$value}}


(If the user set any addresses to the noautoreply table, I don't want to deliver autoreply to these.)
The problem must be here, during the expansion of mysql query. I'd like to create this expansion in that way the
empty list should work as well as a populated list.

I have seen an following example on the Internet:

# Create an addresslist from file
addresslist noautoreply_senders = /var/mail/autoreply.noanswer


# This is the routers section
uservacation:
  driver = accept
  domains = +local_domains
  condition = ${if and{ \
              (blah blah...)
# Expand and negate the addresslist in the senders conditional
  senders = !+noautoreply_senders



and finally the /var/mail/autoreply.noanswer file can contain the addresses:

six@???
tlyons@???
^postmaster@.*
...


Now I'd like to do the same concept but I want it to use per-user settings from MySQL.

> > (By the way, I have another little problem; I set the "log" in the
>> transport section but the file is never created and I couldn't find any particular reason for this.)
>
> You don't specify any user or group for exim to deliver as. If the
> user's maildir is not the same user that exim is running as, then it
> can't create the file(s).


Ah, this must be the solution. I'll try it as soon as possible. Thank you!

Regards,

Imre