SPAM Filters "Block by Domain" blocks partial matches instead of exact domain (blocks gmail.com when blocking mail.com)

Dominik

Verified User
Joined
Dec 23, 2020
Messages
5
Location
Poland
One of our clients reported that he suddenly stopped receiving emails from gmail.com. After investigation, we discovered the cause: he had added a block for the domain mail.com in Spam Filters → Block by Domain.

Contrary to what the interface suggests ("Block by Domain"), the generated filter does not perform an exact domain match. Instead, it uses a simple substring search on the From: header:
Code:
if
        $header_from: contains "mail.com"
then
        seen finish
endif

Because of this, any address containing the string mail.com anywhere is blocked — including [email protected], [email protected], [email protected], etc.

Expected behavior:
The "Block by Domain" option should block only exact domain matches (e.g. [email protected]), not partial strings.

1. Simple fix:
Probably the simplest fix would be adding @ to the searched string, eg:
Code:
if
        $header_from: contains "@mail.com"
then
        seen finish
endif

2. Better solution:
Block both the From header and the envelope sender (MAIL FROM) eg:

Code:
if
        $header_from: contains "@mail.com"
or
        $sender_address_domain is "mail.com"
then
        seen finish
endif
 
Back
Top