Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: exim: users

counting number of adresses in From

 

 

exim users RSS feed   Index | Next | Previous | View Threaded


arekm at maven

Sep 6, 2011, 1:11 AM

Post #1 of 6 (347 views)
Permalink
counting number of adresses in From

exim doesn't have any builtin way to count number of elements.

Recently there are spams with From like this:

From: a [at] 1, b [at] 2, c [at] 3
To: a [at] 1, b [at] 2, c [at] 3

so few addresses in From list.

Looking for something like:
deny message = you are bad
condition = ${if count(${addresslist:$h_From:}) > 1}

--
Arkadiusz Miƛkiewicz PLD/Linux Team
arekm / maven.pl http://ftp.pld-linux.org/

--
## List details at https://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/


tlyons at ivenue

Sep 6, 2011, 6:33 AM

Post #2 of 6 (336 views)
Permalink
Re: counting number of adresses in From [In reply to]

On Tue, Sep 6, 2011 at 1:11 AM, Arkadiusz Miskiewicz <arekm [at] maven> wrote:
>
> exim doesn't have any builtin way to count number of elements.

Yeah, would be nice. For your particular query, there is a recipient
count, but not a sender count, which is what you want.

> Looking for something like:
> deny message = you are bad
>   condition = ${if count(${addresslist:$h_From:}) > 1}

This works for me:
# DEBUG #
warn set acl_m_sender_count = ${reduce \
{>, ${addresses:$h_from:} } \
{ 0 } \
{${eval:$value+1}} \
}
logwrite = Found $acl_m_sender_count senders in From header

...Todd
--
If Americans could eliminate sugary beverages, potatoes, white bread,
pasta, white rice and sugary snacks, we would wipe out almost all the
problems we have with weight and diabetes and other metabolic
diseases. -- Dr. Walter Willett, Harvard School of Public Health

--
## List details at https://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/


arekm at maven

Apr 5, 2012, 4:55 AM

Post #3 of 6 (225 views)
Permalink
Re: counting number of adresses in From [In reply to]

On Tuesday 06 of September 2011, Todd Lyons wrote:
> On Tue, Sep 6, 2011 at 1:11 AM, Arkadiusz Miskiewicz <arekm [at] maven> wrote:
> > exim doesn't have any builtin way to count number of elements.
>
> Yeah, would be nice. For your particular query, there is a recipient
> count, but not a sender count, which is what you want.
>
> > Looking for something like:
> > deny message = you are bad
> > condition = ${if count(${addresslist:$h_From:}) > 1}
>
> This works for me:
> # DEBUG #
> warn set acl_m_sender_count = ${reduce \
> {>, ${addresses:$h_from:} } \
> { 0 } \
> {${eval:$value+1}} \
> }
> logwrite = Found $acl_m_sender_count senders in From
> header

$h_from failed on something, so now using $rh_from and that works well but
there are emails like this:

Date: Wed, 4 Apr 2012 08:14:35 -0500
From: <some [at] aaa>,
<someother [at] bbbb>
User-Agent: Mozilla/5.0

and unfortunately rh_from doesn't contain both addresses - only first one
like:

"<some [at] aaa>,\n"

"The newline that terminates a header line is not included in the expansion,
but internal newlines (caused by splitting the header line over several
physical lines) may be present."

So IMO both lines should be there in $rh_from, right?

--
Arkadiusz Miƛkiewicz PLD/Linux Team
arekm / maven.pl http://ftp.pld-linux.org/

--
## List details at https://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/


exim-users at spodhuis

Apr 6, 2012, 2:51 AM

Post #4 of 6 (222 views)
Permalink
Re: counting number of adresses in From [In reply to]

On 2012-04-05 at 13:55 +0200, Arkadiusz Miƛkiewicz wrote:
> $h_from failed on something, so now using $rh_from and that works well but
> there are emails like this:
>
> Date: Wed, 4 Apr 2012 08:14:35 -0500
> From: <some [at] aaa>,
> <someother [at] bbbb>
> User-Agent: Mozilla/5.0

A continuation line *MUST* start with whitespace. This is fundamental
to email parsing.

If you insert a space at the start of the "<someother".. line, then
$rh_from: and $h_from: both include the full data. If you don't, then
neither does.

Neither one sees more content than the other.

For testing, you can put the above lines into a file "foo" and then run
"exim -bem foo" -- this is like "exim -be", but with many variables
initialised based on the email in file specified on the command-line.

-Phil

--
## List details at https://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/


arekm at maven

Apr 6, 2012, 2:56 AM

Post #5 of 6 (220 views)
Permalink
Re: counting number of adresses in From [In reply to]

On Friday 06 of April 2012, Phil Pennock wrote:
> On 2012-04-05 at 13:55 +0200, Arkadiusz Miƛkiewicz wrote:
> > $h_from failed on something, so now using $rh_from and that works well
> > but there are emails like this:
> >
> > Date: Wed, 4 Apr 2012 08:14:35 -0500
> > From: <some [at] aaa>,
> > <someother [at] bbbb>
> > User-Agent: Mozilla/5.0
>
> A continuation line *MUST* start with whitespace. This is fundamental
> to email parsing.
>
> If you insert a space at the start of the "<someother".. line, then
> $rh_from: and $h_from: both include the full data. If you don't, then
> neither does.
>
> Neither one sees more content than the other.

How to catch emails with such invalid header?

> -Phil

--
Arkadiusz Miƛkiewicz PLD/Linux Team
arekm / maven.pl http://ftp.pld-linux.org/

--
## List details at https://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/


exim-users at spodhuis

Apr 6, 2012, 5:08 AM

Post #6 of 6 (222 views)
Permalink
Re: counting number of adresses in From [In reply to]

On 2012-04-06 at 11:56 +0200, Arkadiusz Miƛkiewicz wrote:
> > > Date: Wed, 4 Apr 2012 08:14:35 -0500
> > > From: <some [at] aaa>,
> > > <someother [at] bbbb>
> > > User-Agent: Mozilla/5.0

> How to catch emails with such invalid header?

Edit the source code, receive.c, around line 1775, to set some variable
based upon this.

Beware that this:
----------------------------8< cut here >8------------------------------
<"some:other"@bbbb.pl>
----------------------------8< cut here >8------------------------------
would be a valid header line, with a header name of '<"some'.

The valid characters for a header-name are the printable US-ASCII
characters. This is dictated by RFC 5322. That line could as well be:
----------------------------8< cut here >8------------------------------
<someother [at] bbbb>:
----------------------------8< cut here >8------------------------------
and '<someother [at] bbbb>' would be the header name. If Exim didn't
accept it, then Exim would be buggy.

I think you may want to consider using separate spam-filtering software
to accomplish your goals.

-Phil

--
## List details at https://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/

exim users RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.