Re: [Exim] Redirecting mail to a Maildir subdirectory

Góra strony
Delete this message
Reply to this message
Autor: Derek Broughton
Data:  
Dla: exim-users
Temat: Re: [Exim] Redirecting mail to a Maildir subdirectory
Greg Ward wrote:


> On 29 November 2001, Derek Broughton said:
> > I'd like to search $header_subject: for "\[.*\]" and, if found, write
> > the message to ~/Maildir/.$subdir (where $subdir is what was found
> > between the brackets). I'd like it even better, if it would just fall
> > through to ~/Maildir if .$subdir doesn't exist.
>
> Obviously, you need to write a filter to do this. But you don't want
> this done by a *system* filter, because that runs once on a message with
> possibly many recipients. You need a per-user filter, but you might not


Thanks. That possibility had completely escaped me...

> want to put it in the user's ~/.forward, because then it's out of your
> control. The solution is a director that runs if the local-part
> corresponds to a local user and that runs the same per-user filter for
> all messages and all recipients.


Exactly. Not that I'm too worried about it being out of my control, just
that it provides a neat way for users to filter mail with no more work than
creating a new IMAP folder.

>   if $header_subject: matches [(\\w+)] then:
>     save Maildir/$1
>   else:
>     save Maildir

>
> This is COMPLETELY UNTESTED and off the top of my head. I didn't even
> check the docs; you should do so to see how badly I've screwed this up.


No problem - I needed pointers not exact solutions :-)

> Also, on re-reading your requirements:
>
> > I'd like to search $header_subject: for "\[.*\]" and, if found, write
> > the message to ~/Maildir/.$subdir (where $subdir is what was found
> > between the brackets).
>
> ...I think you're making several serious mistakes.
>
> First, .* could include slashes, spaces, and other things you don't want
> or can't have in a filename. That's why I used \w+.


hehe - I'd have figured that out - it was really just for simplicity in my
post, not intended to be exact.

> Second, it sounds like you're seriously perverting Maildir. A Maildir
> should contain three subdirectories: new, tmp, and cur. Anything beyond
> that and you risk confusing MUAs, POP/IMAP servers, or whoever is going
> to look at this Maildir.


Not at all. This is exactly correct for the courier-imap server
(courier-popd, too, for that matter). It uses Maildir for INBOX, and then
when you create a subordinate folder it creates it exactly as a new
Maildir-format directory (complete with tmp, cur and new) but named .subdir.
That's one reason why I specifically would like it to fall through to the
existing delivery if the subdirectory doesn't exist - I want the user to
create it via the MUA (and implicitly by courier-imap), which ensures it's
in the correct format.

> Finally, lots of perfectly ordinary mail includes "[...]" in the header
> -- mail from this list, for one. Why should you, the sys-admin, dictate
> how your users sort their mail? If this is for sorting some system
> email, I think you'd be much better off adding a "X-..." header and
> testing for that in your filter.


Who's dictating? Considering what you've posted about what your system
rejects...
I'm offering my users (both of them!) a simple filtering system. It's
specifically _for_ emails like this - so that if you subscribe to a list
that adds [...] in the subject, you can choose to create a special folder
for it. Or not.

I'm not a system administrator, I'm a tinkerer who's having some fun. I
could have done this in my own user filter, but I thought I'd give my wife a
hand. Anyway, adding an X- header would be kind of pointless. If a list
inserts [...] into headers, it probably supplies List- headers, too.
--
derek