[exim] auto-reply with exceptions from SQL lookup

Startseite
Nachricht löschen
Nachricht beantworten
Autor: Veres Imre
Datum:  
To: exim-users
Betreff: [exim] auto-reply with exceptions from SQL lookup
Dear All,

I'm working on the perfect out-of-office/autoreply solution with per-user settings stored in MySQL database. ;-) I stucked with that part when a user can set email addresses whom auto-replies will never be sent to. These addresses can be shared mailboxes, close colleagues etc. The goal is to send vacation autoreply to everyone but these addresses.

I'd like to solve this with the "senders" keyword where I could negate all the addresses which are on the database table. Every other functions work perfectly except this. I hope you can point out what went wrong.

The problem is that the autoreply message is going to be sent doesn't matter whether the address was listed in the database or not.

As I told I use Mysql; users table contains localpart and the userid, domains table the domain name and domain_id, and I have created a table called "noautoreply" which contains user_id reference and the address that should be excluded from autoreply function.

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}} \
                {!def:header_List-Id: } \
                {!def:header_X-Autoreply-From: } \
                {!match {$h_Subject:} {\N(Out of Office)$\N} } \
                {!match {$h_Subject:} {\N(Auto Reply)\N} } \
                {!match {$h_Subject:} {\N(Auto-Reply)\N} } \
                 }}
    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}}
    no_verify
    no_expn
    unseen
    transport = virtual_vacation_delivery


Transport section:

virtual_vacation_delivery:
    driver      = autoreply
    once        = /var/spool/exim4/db/vacation_${local_part}_${domain}.db
    once_repeat = 7d
    log         = /var/mail/${domain}/${local_part}/vacation.db


    from     = "${local_part}@${domain}"
    to       = ${sender_address}
    subject  = ${if def:h_subject: \
                {${lookup mysql{select vacation_subject from users,domains \
                where domain='${quote_mysql:$domain}' \
                and localpart='${quote_mysql:$local_part}' \
                and users.domain_id=domains.domain_id}{$value}fail} ${rfc2047:${quote:${escape:${length_60:$h_subject:}} }} }\
                {Auto: ${local_part}@${domain}} \
               }
    text     = ${lookup mysql{select vacation from users,domains \
                where \
                domain='${quote_mysql:$domain}' \
                and localpart='${quote_mysql:$local_part}' \
                and users.domain_id=domains.domain_id}}



(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.)

Can you guide me to the solution, please?

Six