Re: [exim] String expansion - deleting everything but a spec…

Top Page
Delete this message
Reply to this message
Author: Ted Cooper
Date:  
To: 'Exim-users@exim.org'
Subject: Re: [exim] String expansion - deleting everything but a specified setof characters from string
Marcin Krol wrote:
> Hello everyone,
>
> I'd like to use maildir_tag containing subject of mail in transport, but with characters undesirable in filename converted to underscores.
>
> I configured the following and it works:
>
> maildir_tag = T=${sg{${from_utf8:$acl_m_subject}}{\N[!@#$%^&*()~ {}\]\]\|"'`;\:/\?<>,\.]\N}{_}}-S=$message_size
>
> ...but it looks terrible, it's error prone and some characters might still slip through instead being converted to underscores as intended.
>
> I suspect some ${sg magic might work, along the lines:
>
> ${sg{$acl_m_subject}{\N([a-zA-Z0-9]+)([a-zA-Z0-9]+)([a-zA-Z0-9]+)([a-zA-Z0-9]+)\N}{\$1\$2\$3\$4}}
>
> But this is not much better really.
>
>
> --
> Marcin Krol
>
>
>


You're going to end up with filenames longer than your file system can
handle. I can't remember what the actual limit is but I have run into it
before and ended up with files that I could only access if I shortened
the mount location.
Greping the subject out of the mail is as easy as pie though and will
give you the filename & subject together.

grep ^Subject: /path/to/dir/holding/maildir

I use that for very quickly checking that my spamtrap spam really is spam.

I'm afraid I can't actually offer any real help other than warnings and
an easy grep :P I need several hours and a caffeine I.V. to do anything
with regex.

--
The Exim Manual
http://www.exim.org/docs.html
http://www.exim.org/exim-html-current/doc/html/spec_html/index.html