RegExp help

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

RegExp help

Barbara M.-2

I am trying to use regexp to block mails from specific domains to specific
users (and let other users receive it).

I need to merge (logical AND operator), something like:

/^From:.*\@.*domainsource.tld/      REJECT  No Unrequested mail Please
/^To:.*\@.*domaindest.tld/      REJECT  No Unrequested mail Please

For my needs I want these rules evaluated in AND.

How can do this with a valid rules in my /etc/postfix/header_checks?
If there is a better solution ... ;-)

Thanks, B.

Reply | Threaded
Open this post in threaded view
|

Re: RegExp help

jason hirsh
I have bene using 




for test and evaluation    It has also helped on my composition



On May 14, 2015, at 6:48 AM, Barbara M. <[hidden email]> wrote:


I am trying to use regexp to block mails from specific domains to specific users (and let other users receive it).

I need to merge (logical AND operator), something like:

/^From:.*\@.*domainsource.tld/      REJECT  No Unrequested mail Please
/^To:.*\@.*domaindest.tld/      REJECT  No Unrequested mail Please

For my needs I want these rules evaluated in AND.

How can do this with a valid rules in my /etc/postfix/header_checks?
If there is a better solution ... ;-)

Thanks, B.


Reply | Threaded
Open this post in threaded view
|

Re: RegExp help

Barbara M.-2
On Thu, 14 May 2015, jason hirsh wrote:

> I have bene using 
>
> https://regex101.com
>
> for test and evaluation    It has also helped on my composition

Cool.
But I can't still find a solution.
I am not a regex expert (obiviosly).
I write simple expression when needed, but I can't find how to improve the
AND condition.
Tried solutions like:

/.*\@.*domainsource.tld.*\@.*domaindest.tld/      REJECT
/.*\@.*domaindest.tld.*\@.*domainsource.tld/

without success.
Surely it is a trivial trick that I don't see :-(

Thanks, B.





>       On May 14, 2015, at 6:48 AM, Barbara M. <[hidden email]> wrote:
>
>
> I am trying to use regexp to block mails from specific domains to
> specific users (and let other users receive it).
>
> I need to merge (logical AND operator), something like:
>
> /^From:.*\@.*domainsource.tld/      REJECT  No Unrequested mail Please
> /^To:.*\@.*domaindest.tld/      REJECT  No Unrequested mail Please
>
> For my needs I want these rules evaluated in AND.
>
> How can do this with a valid rules in my /etc/postfix/header_checks?
> If there is a better solution ... ;-)
>
> Thanks, B.
>
>
>
>
Reply | Threaded
Open this post in threaded view
|

Re: RegExp help

jason hirsh

> On May 14, 2015, at 7:41 AM, Barbara M. <[hidden email]> wrote:
>
> On Thu, 14 May 2015, jason hirsh wrote:
>
>> I have bene using
>> https://regex101.com
>> for test and evaluation    It has also helped on my composition
>
> Cool.
> But I can't still find a solution.
> I am not a regex expert (obiviosly).
> I write simple expression when needed, but I can't find how to improve the AND condition.
> Tried solutions like:
>
> /.*\@.*domainsource.tld.*\@.*domaindest.tld/      REJECT
> /.*\@.*domaindest.tld.*\@.*domainsource.tld/
>
> without success.
> Surely it is a trivial trick that I don't see :-(

In you choice of sample domains names it seems like you are trying to get mail from a location (domainsource.tld)  going to
a location  (domaindest.tld)

if domainsource.tld has no valid email  I would try  

\/.*(.*domainsource.tld.*)/

Put this in the tester brining in information from the raw message and tweak the wildcards till you get a match



but I am no expert in this  

>
> Thanks, B.
>
>
>
>
>
>>      On May 14, 2015, at 6:48 AM, Barbara M. <[hidden email]> wrote:
>> I am trying to use regexp to block mails from specific domains to
>> specific users (and let other users receive it).
>> I need to merge (logical AND operator), something like:
>> /^From:.*\@.*domainsource.tld/      REJECT  No Unrequested mail Please
>> /^To:.*\@.*domaindest.tld/      REJECT  No Unrequested mail Please
>> For my needs I want these rules evaluated in AND.
>> How can do this with a valid rules in my /etc/postfix/header_checks?
>> If there is a better solution ... ;-)
>> Thanks, B.

Reply | Threaded
Open this post in threaded view
|

Re: RegExp help

Tom Hendrikx
In reply to this post by Barbara M.-2
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

On 14-05-15 12:48, Barbara M. wrote:

>
> I am trying to use regexp to block mails from specific domains to
> specific users (and let other users receive it).
>
> I need to merge (logical AND operator), something like:
>
> /^From:.*\@.*domainsource.tld/      REJECT  No Unrequested mail
> Please /^To:.*\@.*domaindest.tld/      REJECT  No Unrequested mail
> Please
>
> For my needs I want these rules evaluated in AND.
>
> How can do this with a valid rules in my
> /etc/postfix/header_checks? If there is a better solution ... ;-)

Header checks doesn't do AND for multiple headers, all headers get
evaluated separately. For this idea, you'd need a content filter.
Within Spamassassin these kind of rules are trivial.

Regards,
        Tom
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iQIcBAEBCAAGBQJVVI2KAAoJEJPfMZ19VO/188wQAKPF4NagLlnxnkTX7/7nCBEF
X9Fa4SvVocYFhA9dz9csmT6bN1vmADnkDHl02vAvBIhWszu5ghESI57/oeVhfuXn
9oapH/cfx6xuj4xsoA92zV0FuPfQu9jEUIC7rEi3A8K7nmjGTs3M/isU/8YiQn4C
hsORxhaKP2WCLylUk6KdOhrObZ3KlJwaIEETSl146g/ZG53YSJFeG29Zp/ksFu+H
5+VZEPnWb1sbwG6H59uUQ4vY+V/63fw6aZYfUdD3xgFuZbdJO738BoI/lLc8KssU
L+b5isQhq0D78pLPlMkG9dkKjHyZXCuhkTEAvtbZGxy/Rfz86toafr7IZq8GaYuh
XPM2KYzOZeDqeM53BWQ0UF0XR/jx4yBi1wQd7un1wJA+ZFGLxhlQdSav5Vt7y8Et
4UAAzWZ3jT+ESVJQ+3OlDin+ge4i8xNYKH28hxS5KDktkAk0k5tCpesn67jt+gqQ
CacO7tSYL6zJyrVDIXqwZIDtu1hQh3fo6Sty/Xi6B5MRBt0YCj4bv6qNW7PtuNQm
oQ3NEDex2PdsVS0E2JDaaLG+aSdWeSesWHvO6H4CWe1hdKHKDHwfVMTBBBZZ8Y/v
aXoMItPDM+mhp2MjvKza0RLQZWYZ9ig7yYQzlMQGoiMvZEKES5ZOX1BUMxIiBzuk
nVwTf7NZmlvgWPcqL0os
=s6lF
-----END PGP SIGNATURE-----
Reply | Threaded
Open this post in threaded view
|

Re: RegExp help

Barbara M.-2
On Thu, 14 May 2015, Tom Hendrikx wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA256
>
> On 14-05-15 12:48, Barbara M. wrote:
>>
>> I am trying to use regexp to block mails from specific domains to
>> specific users (and let other users receive it).
>>
>> I need to merge (logical AND operator), something like:
>>
>> /^From:.*\@.*domainsource.tld/      REJECT  No Unrequested mail
>> Please /^To:.*\@.*domaindest.tld/      REJECT  No Unrequested mail
>> Please
>>
>> For my needs I want these rules evaluated in AND.
>>
>> How can do this with a valid rules in my
>> /etc/postfix/header_checks? If there is a better solution ... ;-)
>
> Header checks doesn't do AND for multiple headers, all headers get
> evaluated separately. For this idea, you'd need a content filter.

So it isn't so trivial as I thought ... :-(

> Within Spamassassin these kind of rules are trivial.

I use SA in default config. Never tried to customize rules, so, may be it
isn't trivial for me. :-)
N.B.: I want mail rejected from Postfix not marked as spam and delivered.
If SA can do this I try it (better if someone give me some example/hints
for the .cf ;-))

Thanks, B.

Reply | Threaded
Open this post in threaded view
|

Re: RegExp help

Michael Orlitzky-2
On 05/14/2015 10:41 AM, Barbara M. wrote:
>
> I use SA in default config. Never tried to customize rules, so, may be it
> isn't trivial for me. :-)
> N.B.: I want mail rejected from Postfix not marked as spam and delivered.
> If SA can do this I try it (better if someone give me some example/hints
> for the .cf ;-))
>

If the to/from rules aren't very fine-grained, then maybe you want to
put the senders or recipients into restriction classes?

  http://www.postfix.org/RESTRICTION_CLASS_README.html

Reply | Threaded
Open this post in threaded view
|

RE: RegExp help

Marius Gologan
In reply to this post by Barbara M.-2
If you want to design a solution that can reject the messages during SMTP
connection (before accepting any data) based on your criteria (sender AND
recipient), you need check_policy_service in Postifx.
http://www.postfix.org/SMTPD_POLICY_README.html

For large scale, you may use almost any programming or scripting language
and a database. For you particular case, I would go with Redis db.


-----Original Message-----
From: [hidden email]
[mailto:[hidden email]] On Behalf Of Barbara M.
Sent: Thursday, May 14, 2015 5:41 PM
To: Tom Hendrikx
Cc: [hidden email]
Subject: Re: RegExp help

On Thu, 14 May 2015, Tom Hendrikx wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA256
>
> On 14-05-15 12:48, Barbara M. wrote:
>>
>> I am trying to use regexp to block mails from specific domains to
>> specific users (and let other users receive it).
>>
>> I need to merge (logical AND operator), something like:
>>
>> /^From:.*\@.*domainsource.tld/      REJECT  No Unrequested mail
>> Please /^To:.*\@.*domaindest.tld/      REJECT  No Unrequested mail
>> Please
>>
>> For my needs I want these rules evaluated in AND.
>>
>> How can do this with a valid rules in my
>> /etc/postfix/header_checks? If there is a better solution ... ;-)
>
> Header checks doesn't do AND for multiple headers, all headers get
> evaluated separately. For this idea, you'd need a content filter.

So it isn't so trivial as I thought ... :-(

> Within Spamassassin these kind of rules are trivial.

I use SA in default config. Never tried to customize rules, so, may be it
isn't trivial for me. :-)
N.B.: I want mail rejected from Postfix not marked as spam and delivered.
If SA can do this I try it (better if someone give me some example/hints
for the .cf ;-))

Thanks, B.


Reply | Threaded
Open this post in threaded view
|

Re: RegExp help

AnthonyL
In reply to this post by jason hirsh
On Thu, 14 May 2015 06:57:16 -0400, jason hirsh wrote:

> I have bene using
>
> https://regex101.com <https://regex101.com/>
> for test and evaluation    It has also helped on my composition

Thanks very much for that one. It's just what I was looking for.