Re: [exim] saving substr result?

Page principale
Supprimer ce message
Répondre à ce message
Auteur: Magnus Holmgren
Date:  
À: exim-users
Sujet: Re: [exim] saving substr result?
On Friday 16 March 2007 15:57, Don Walker wrote:
> Is there any way to set a variable to preserve the result of substr in a
> router acl? My need is to extract two substrings from $local_part and
> use them in a condition and mysql query. The code below works, but it
> would be cleaner if the two substr uses could be coded once and the
> results saved for use in the rest of the code. I have scoured all the
> docs I can find and tried to set acl_mX.


You don't strictly need the condition. Plus, you don't need the second
argument to substr when you want the rest of the string. And I think you can
use the in operator in the query.

 maillist:
   driver = redirect
   data = ${lookup{${substr{0}{5}{$local_part}}}lsearch{/etc/exim/maillists}
             {${lookup mysql{select email from $value \
                             where ${substr{5}{$local_part}} \
                                   in (class1, class2, class3)}}}


The first lookup searches /etc/exim/maillist. If the key given by the first
five characters $local_part is found, the value is put in $value and the
true-branch of the lookup item is expanded. In this case it's a second
lookup. If either lookup fails to find any data, the router declines. This
isn't exactly the same as the condition not matching, but it only matters if
no_more is set (and possibly some more situation that I might have
forgotten.)

-- 
Magnus Holmgren        holmgren@???
                       (No Cc of list mail needed, thanks)


"Exim is better at being younger, whereas sendmail is better for
Scrabble (50 point bonus for clearing your rack)" -- Dave Evans