[Exim] saving to relative paths in filters for virtual users

Startseite
Nachricht löschen
Nachricht beantworten
Autor: Nico Erfurth
Datum:  
To: exim-users
Betreff: [Exim] saving to relative paths in filters for virtual users
Hi,

i used exim 3.x with xams, and some weeks ago i moved to 4.x and i'm
impressed, but there is one thing that i don't liked. In exim3.x we
could set the users home_directory with a trick, so it was possible to
use something like

save .Exim/

in your filterfile, and the mail was saved to a directory under the
"virtual-home-directory" of our user. This trick does not work anymore
for exim4, and i switched to use full-paths instead (but i don't liked it).

Some days ago i read a thread about someone who had the same problems
than me, and so i thought, there must be a way to fix it, and there is one.

My pmail_forward router now looks like this:

pmail_forward:
   driver = redirect
   allow_filter
   check_ancestor
   no_check_local_user
   no_expn
   require_files = "USERHOME/$local_part.filt"
   data =  ${sg {${readfile{USERHOME/$local_part.filt}}} \
     {save\\s+([^/].*)\\s*}{save USERHOME/$local_part/\$1\\n}}
   file_transport = pmail_delivery
   pipe_transport = address_pipe
   reply_transport = address_reply
   directory_transport = pmail_delivery
   retry_use_local_part
   user = mail
   no_verify


USERHOME is a macro that looks up the "home directory" of our virtual user,
My one:

USERHOME = /var/imap/${lookup mysql{SELECT s.Name FROM pm_domains d,
pm_sites s, pm_users u WHERE s.ID = d.SiteID AND d
.Name = '$domain' and u.Name = '$local_part' and u.SiteID = s.ID AND
s.SiteState != 'locked_bounce' AND u.AccountState
!= 'locked_bounce'}{${value}}}/

The trick is, we read the whole filterfile, and "preprocess", by using
${sg} we search for    save (RELATIVE-PATH) and replace it with save
USERHOME/RELATIVE-PATH


This one works for me, i would be glad if someone with the same problem
could test this solution and give some response.

ciao
Nico

P.S. Thanks to PH for this GREAT MTA, IMHO it's the most powerful one i
ever used, and it makes most impossible things possible.