Re: [Exim] pcre for several recipients with same username

Página superior
Eliminar este mensaje
Responder a este mensaje
Autor: Philip Hazel
Fecha:  
A: Jeremy C. Reed
Cc: exim-users
Asunto: Re: [Exim] pcre for several recipients with same username
On Wed, 30 Jan 2002, Jeremy C. Reed wrote:

> I am trying to figure out how I can block emails that have several
> recipients with the same username. (Examples below after signature.)


For your specific examples, something like

if $cc contains ${local_part:$h_to:}

might do the trick. It's not "right", of course, since To: might contain
more than one address.

As you pointed out in another posting, $original_local_part is no good.
There are several reasons for this (1) there is no one "local part" when
a system filter is running; (2) in any case, $[original_]local_part
applies to the envelope recipient of a message, not to what appears in
the header lines.

What you really need to do in a system filter is to analyze the contents
of $recipients (assuming that there are multiple envelope recipients). I
can conceive of a regex that pulls out the local part of the first
recipient on the list, and checks to see if that string occurs later in
the list, but doing anything more complicated needs more logic than a
regex can provide, I suspect. Hmm. No, wait. Maybe one could write one
which marched along the list, picking out local parts, and looking for
them later in the list. Something like this (ignore white space and
comments)

(?>[^,]+,\s*)*      # skip addresses one by one; don't recurse into them
([^@]+)@            # pick out a local part
(?:.*?)             # skip an arbitrary number of chars, minimally
\1@                 # match the picked out local part


Completely untested. Not even guaranteed to work at all. Just an idea
that popped into my head. Needs lots of testing and refining. You
probably ought to skip over domains somehow. Regex are your friend, but
they can be hard work!

--
Philip Hazel            University of Cambridge Computing Service,
ph10@???      Cambridge, England. Phone: +44 1223 334714.