Re: [exim] Users Forward File

Top Page
Delete this message
Reply to this message
Author: Michael Sprague
Date:  
To: exim-users
Subject: Re: [exim] Users Forward File
Joseph wrote:
> Hi all,
>
> I am working on a setup that uses pgsql to reference the users (vexim).
>
> And in looking at samples I am not able to figure out how I would use a
> .forward file.
>
> I guess I don't understand check_local_user... If that is in the router,
> than it wants to check for a system user, and there won't be system
> users since users are defined in pgsql.
>
> Removing check_local_user, makes it complain:
> "user" or "check_local_user" must be set with "allow_filter"
> Which should be my clue to the problem.
>
> I should be using pgsql to store the .forward contents I expect, but I
> am not sure how to do that either.

<SNIP>

Hi Joseph,

I've started playing with the same basic thing: .forward like files with
vexim. Specifically I'm building a new mail server just for myself and
I want to use the exim filter language to sort my incoming mail on the
server side.

Here is a router that I'm still playing with. It works in general but I
have not really tested it for security implications yet. I basically
took the userforward router in the Debian conf files and modified it:

# Query macros
POP = ${lookup mysql{select pop from users,domains where localpart =
'${quote_mysql:$local_part}' and domain = '${quote_mysql:$domain}' and
domains.enabled = '1
' and users.enabled = '1' and users.domain_id = domains.domain_id}}
QUOTED = ${lookup mysql{select pop from users,domains where localpart =
'${quote_mysql::$local_part}' and domain = '${quote_mysql::$domain}' and
domains.enabled = '1' and users.enabled = '1' and users.domain_id =
domains.domain_id}}

# Look for a user's .mfilter file and process if any.
mfilter:
   debug_print = "R: mfilter for $local_part@$domain"
   driver = redirect
   file = POP/.forward
   require_files = vexim:QUOTED/.forward
   no_verify
   no_expn
   check_ancestor
   allow_filter
   user = vexim
   forbid_smtp_code = true
   directory_transport = address_directory
   file_transport = address_file
   pipe_transport = address_pipe
   reply_transport = address_reply
   skip_syntax_errors
   syntax_errors_to = real-$local_part@$domain
   syntax_errors_text = \
     This is an automatically generated message. An error has\n\
     been found in your .mfilter file. Details of the error are\n\
     reported below. While this error persists, you will receive\n\
     a copy of this message for every message that is addressed\n\
     to you. If your .forward file is a filter file, or if it is\n\
     a non-filter file containing no valid forwarding addresses,\n\
     a copy of each incoming message will be put in your normal\n\
     mailbox. If a non-filter file contains at least one valid\n\
     forwarding address, forwarding to the valid addresses will\n\
     happen, and those will be the only deliveries that occur.


Some key points:

o I'm using mysql rather than postgres but that shouldn't matter much.
o I like to use macros to store common database queries b/ they can be
so long.
o The require_files line is doing the stat at user 'vexim'. This is the
user that owns the stored mail directory tree on my system.
o The POP and QUOTED macros are identical except that the QUOTED one has
the double colons. This is so that it will work in the require_files
line which needs the colons to be quoted.
o I'm still working on another router to handle the
'real-$local_part@$domain' address. I will be using the one from the
Debian conf and just modifying.

My initial tests have worked in that an incoming message will be
processed by the .forward file in the user's mail storage directory.
I'm still adding rules to the .forward and testing to see that they get
delivered into the correct folder, etc, etc.

I hope this helps at least a little. Any thoughts from the community
are quite welcome as well.

thanks,
mikeS

-- 
Michael F. Sprague     | mfs@???
http://www.saneinc.net | Provider of SpamOnion anti-spam service
System and Network Engineering (SaNE), Inc