OK, so this configuration seems to work fine.

 

/^From:.*<.*(\[|\]|\(|\)|\`|\;|\,|\^|\#|\:|\||\\|\@|<|>|\/|\!|\
|\$|"|"|\%|\&|').*@.*>/ REJECT "3 - Your Email address is not compliant with
RFC, Go Away"

if !/^From:.*<.*@.*>/

/^From:.*([|]|\(|\)|`|;|,|^|#|:|\||\\|@|<|>|\/|!|$|"|%|&|').*@/ REJECT "4 -
Your Email address is not compliant with RFC, Go Away"

Endif

 

In fact, for the regexp REJECT 4, if I leave \s, then all header From:
u...@domain.tld are rejected, but with this one

 

postmap -q "From: u&s...@domain.tld" regexp:/etc/postfix/regexp_table returns
REJECT "4 - Your Email address is not compliant with RFC, Go Away"

postmap -q "From: u...@domain.tld" regexp:/etc/postfix/regexp_table returns
ACCEPT

 

I don’t really need the same thing for the domain part as I reject all the
mail with an invalid domain name.

 

Any idea for the REJECT 4 to reject the header “From: us e...@domain.tld", ie
with a space in the first part.

 

Thanks for your help

 

 

Franck
-------------------------------------------
E:  <mailto:m...@civis.net> m...@civis.net

 

De : owner-postfix-us...@postfix.org
[mailto:owner-postfix-us...@postfix.org] De la part de Jeroen Geilman
Envoyé : lundi 14 février 2011 00:44
À : postfix-users@postfix.org
Objet : Re: Issue with header_checks

 

On 02/14/2011 12:37 AM, Franck MAHE wrote: 

I did the test on the From header, so I don’t understand why the if
!/^From:.* <mailto:.*@.*> <.*@.*>/ don’t catch 





header From: use <mailto:use&r...@domain.tld> &r...@domain.tld


A. It does catch that, since it doesn't contain either < or >.
But 
B. That is unlike anything you have shown before.

However, your regex for case #4 only requires the LAST character of the
locapart to be invalid.



 

I want to catch all character not compliant with the standard in the From
Header.


Then use that range of invalid characters and forbid it anywhere in the
localpart:

/^From:.*[[\]()`;,\^#:|\\@<>/! $"%&'].*@.*/

Repeat it in the domain part if you so desire.





 

Franck
-------------------------------------------
E:  <mailto:m...@civis.net> m...@civis.net

De : owner-postfix-us...@postfix.org
[mailto:owner-postfix-us...@postfix.org] De la part de Jeroen Geilman
Envoyé : lundi 14 février 2011 00:16
À : postfix-users@postfix.org
Objet : Re: Issue with header_checks

 

On 02/14/2011 12:13 AM, Franck MAHE wrote: 

Hi,

 

OK, but the REJECT 3 works fine, so I think it is an issue with the if, but
I don’t see why.

 


Define "works fine".
What headers did you test, and what was the result ?





 

Franck
-------------------------------------------
M: +33 6 6042 7249
E: m...@civis.net

De : owner-postfix-us...@postfix.org
[mailto:owner-postfix-us...@postfix.org] De la part de Jeroen Geilman
Envoyé : dimanche 13 février 2011 23:49
À : postfix-users@postfix.org
Objet : Re: Issue with header_checks

 

On 02/13/2011 10:33 PM, Franck MAHE wrote: 

Hello,

 

I’ve the following in main.cf

header_checks = regexp:/etc/postfix/regexp_table

 

My postfix release is 2.3.8

 

I’ve the following in my header_checks regex table:

# MAL FORMATED EMAIL ADDRESS

/^From:.*\.@.*/         REJECT "1 - Your Email address is not compliant with
RFC, Go Away"

/^From:.* <mailto:.*%5C.%5C..*@.*> <.*\.\..*@.*>/ REJECT "2 - Your Email
address is not compliant with RFC, Go Away"

/^From:.*<.*(\[|\]|\(|\)|\`|\;|\,|\^|\#|\:|\||\\|\@|<|>|\/|\!|\
|\$|"|"|\%|\&|').*@.*>/ REJECT "3 - Your Email address is not compliant with
RFC, Go Away"

if !/^From:.* <mailto:.*@.*> <.*@.*>/

/^From:.*(\[|\]|\(|\)|\`|\;|\,|\^|\#|\:|\||\\|\@|<|>|\/|\!|\ |\$|"|
<mailto:%7C%5C%25%7C%5C&%7C%27%29@.*/%A0%A0%A0%A0REJECT> "|\%|\&|')@.*/
REJECT "4 - Your Email address is not compliant with RFC, Go Away"

endif

 

All is fine for REJECT 1, 2 & 3, however when the From field is only “From:
u...@domain.tld”, the REJECT 4 is not taken into account, ie the REJECT 4
seems not to be tested. So, it seems that the if…endif block is not working.

 

Do you have any idea to solve that?

 

Franck
-------------------------------------------
E: m...@civis.net


“From: u...@domain.tld” does not match
/^From:.*(\[|\]|\(|\)|\`|\;|\,|\^|\#|\:|\||\\|\@|<|>|\/|\!|\
|\$|"|"|\%|\&|')@.*/

The regex requires the locapart to end with one of the listed characters;
your example does not, it is perfectly valid.

I would also implore you to use character classes to make this less
unreadable:

    /^From:.*[[\]()`;,\^#:|\\@<>/! $"%&']@.*/

In a regex character class, almost all characters lose their special
meaning, so they don't have to be escaped.

But as stated above, requiring one of these characters between the localpart
and the @ sign will not match the valid address you gave as an example.






-- 
J.







-- 
J.






-- 
J.

Reply via email to