Too much spam: filters, block lists, trusted senders

In accounting, Jack Green and Julia Brown receive about ten messages a day of "special offers" from always-different addresses, all from the domain special-offers.test. Meanwhile the server of…

Situation

In accounting, Jack Green and Julia Brown receive about ten messages a day of “special offers” from always-different addresses, all from the domain special-offers.test. Meanwhile the server of John Smith Ltd sees hundreds of connections a day from the same address, 203.0.113.66. On the other hand, the invoice of a genuine supplier, supplier.test, ends up in «Junk».

These are three faces of the same job: tuning the filter. Atlas does it with lists (no threshold to touch, no rule to write): each list has a precise effect on a message’s score or on acceptance at the door, and the console tells you which next to each one. The scenario takes you in this order:

  1. measure the problem (how much spam gets through, from where);
  2. understand why a specific message got through;
  3. choose the right list, from the softest to the hardest;
  4. fix the false positives, that is, good mail mistaken for spam;
  5. check that the consent lists are not a hole.

The principle is one: start from the lightest measure that is enough. A wrong block list loses real mail, and of that you have no trace.

What you need

  • A console administrator account (lwhite) and the Mail module installed (the Mail items appear only with the module).
  • At least one sample spam message still in a mailbox, or the approximate date it arrived.
  • The filter service running (the amber label «Filter service not running» in Mail → Filters and lists says otherwise).

Steps

1. Measure the problem

  1. Open System → Status, «Antispam» panel: a pie chart with the filter’s actions («Passed», «Greylist», «Header», «Rewrite», «Soft reject», «Reject») and the period covered. If «Passed» is much bigger than «Reject» and «Header», the filter lets everything in.
  2. Open Mail → Logs and choose the «Traffic» view. Look at the rankings «Top senders» and «Top sending hosts» for the last 24 hours. A host or a domain that appears at the top with hundreds of messages is your target. In the example 203.0.113.66 is the first of the sending hosts.
  3. In the totals also look at «Bounced» and «Rejected»: if they rise while the user complains about spam, the server is already discarding a lot and what gets through is the rest.

2. Understand why it got through

  1. Open Mail → Filters and lists and select «Recent messages»: these are the latest messages analysed by the filter.

  2. In the search type special-offers.test. Each message has a subject, sender, recipients, the symbols that affected the score, the verdict and the score in the form score / threshold.

  3. Read the verdict of those the users have seen:

    Verdict Means What you infer
    «Delivered» The score stayed under the threshold The filter does not recognise it as spam: you need lists (step 3)
    «Marked as spam» Over the threshold, delivered to «Junk» The filter works, the user sees it in the spam folder
    «Subject marked» Delivered with a tag in the subject Same
    «Refused» Rejected at delivery It does not arrive in the mailbox
    «Delayed», «Deferred» The sender is asked to retry later Slows down burst spam
  4. Look at the symbols of a «Delivered» but unwanted message: if there are no strong ones, the sender is “clean” for the filter (new, with its SPF and DKIM in order). A filter does not recognise the spam of a sender that knows how to authenticate: that is why lists are needed.

Warning Lists compare the sender as the message declares it. A spammer who changes domain every day escapes a list of domains: against them the IP address of the server they send from matters more, being harder to change.

3. Choose the list, from the softest to the hardest

The lists are in the left column of Mail → Filters and lists. The coloured dot tells the nature: green consent, red block. For spam you need the red ones.

  1. First move: penalise, do not refuse. Select «Penalised senders» and press «Add entry». In the «Domain» field type special-offers.test (the domain only, with no @ or address), in the «Note» field (optional, but you will be grateful in six months) offer spam, October. Press «Add». The list raises the spam score by 8 points and delivers the message anyway: if you got the domain wrong you lose nothing, and normally 8 points are enough to send it to «Junk». The entries of this list are applied immediately, without restarts.
  2. Second move, if that is not enough: refuse the domain. Select «Refused senders» and add special-offers.test in «Domain or address». The server refuses at the door every message that declares that domain: nothing is delivered or kept, and a legitimate sender would receive an error. Use it only for domains you are sure about. Notice: this list acts on the mail server and with every change it “restarts the SMTP service: for a few seconds incoming mail waits and the senders retry it”.
  3. For a host that hammers the server: block the IP. Select «Refused connections» and press «Add entry». «IP address or range»: 203.0.113.66; «Verdict»: «Refuse» (default). It is the cheapest point at which to block: the decision is taken before the SMTP conversation even begins. For a whole network use the prefix form (203.0.113.0/24).
  4. Two more IP lists, depending on what you measured: «Refused addresses» (any connection from those addresses is refused) and «Penalised addresses» (+8, like the domain list, but per IP address). They are used in two steps, as for domains: first penalise, then refuse.
  5. If an address is not valid, the form says so (an IPv4 or a CIDR range; a value with spaces or # is not). If the entry is already there: «Already in this list».

For the technician «Penalised senders» and «Penalised addresses» are rspamd maps (+8): the scores are fixed in the console and cannot be changed. The Postfix lists («Always accepted senders», «Refused senders», «Refused addresses», «Refused connections») write Postfix tables and restart SMTP. An entry cannot be edited: to change it you remove it (bin «Remove», confirmation «Remove this entry?») and add it again.

4. Fix the false positives (good mail in spam)

The reverse of spam is the invoice from supplier.test that ended up in «Junk». Here you work with the green lists, and you choose the safest one that works.

  1. In Mail → Filters and lists → Recent messages search for supplier.test. You find the message with «Marked as spam» and its score.
  2. Press «Trust the sender’s domain» and confirm. The console chooses by itself: if the domain publishes DMARC it puts the entry in «Trusted senders (verified)» (−7 points, valid only if the sender authenticates: whoever forges the domain gets nothing), otherwise in «Trusted senders (unverified)» (−2, but anyone can pass themselves off as that domain: the question says so).
  3. «Sender added to — Trusted senders (verified)» appears (or «unverified»). Trust lowers the score, it does not guarantee delivery.
  4. If the message still ends up in spam, two ways in order:
    • «Trusted senders (SPF and DKIM)» for those who sign but do not publish DMARC (−3, valid only if SPF and DKIM both succeed);
    • as a last resort, «Always deliver» (−20): it overrides the antispam for that domain, and does not verify the sender. Read the notice in the form; the domain cannot be a public mail service (gmail.com): the console refuses it with «It is a public mail service: trusting it would mean trusting anyone with a mailbox there».
  5. When you add a domain to the “Trusted senders” lists, as soon as you leave the field the console queries the domain’s DNS and warns you whether the entry would be of use: «This domain publishes SPF but no DMARC: this entry would never apply. Use Trusted senders (unverified).» or «This domain publishes DMARC, so the verified whitelist will work». Believe the console: it saves you rules that never fire.

Every consent list is an exception to the filter. An entry forgotten, years later, lets spam through.

  1. For each of «Trusted senders (unverified)», «Trusted addresses», «Always deliver» and «Always accepted senders» scroll the list: each entry with its «Note» explains itself; those without a note or that you do not recognise must be checked.
  2. A temporary address (in the example 198.51.100.90, the old server during a migration) must be removed when the work is done: a forgotten trust is a hole.
  3. Remember the order: «Always accepted senders» win over «Refused senders» (a refusal entry that is also among the accepted ones is flagged with «Never applied: this sender is also in Always accepted senders, which wins.»). If a domain you want to block is among the accepted ones, first remove the entry there.

6. Optional: antispam with local artificial intelligence

  1. In System → Settings → Mail server, «Antispam» section, there is the switch «Enable AI for Antispam»: it runs a local model on the appliance, which the antispam uses in its evaluation. Turning it on installs a background service and takes a few minutes; the first time it downloads the model. Turning it off frees about 3 GB of memory.
  2. If the processor lacks the AVX/AVX2/FMA instructions, «CPU instructions missing on the host: …» appears in red under the switch: without them the model is about five times slower and many emails exceed the time limit without being evaluated. In a virtual machine set the CPU type to “host” in the hypervisor.
  3. Before turning AI on in a modest appliance, check the «Hardware» panel of System → Status: free memory and CPU are needed. AI helps the filter, but the spam of a “clean” sender is stopped by the lists anyway.

Check

  • In the Recent messages the new messages from special-offers.test have a higher score (8 points more) and the label «Marked as spam» (or «Refused» if you used the refusal).
  • The entries you added appear in their lists, with their count in the column and the note.
  • In Mail → Logs → Traffic the number of «Rejected» goes up and the connections from 203.0.113.66 no longer appear among the «Top sending hosts»; in System → Status «Reject» grows in the «Antispam» panel.
  • The supplier’s next invoice arrives in «Inbox»; if the last one was already in «Junk», Jack moves it by hand.
  • After a few days ask Jack and Julia whether they still see any: if so, go back to step 2 on a new message.

If something goes wrong

Symptom Likely cause Remedy
Spam arrives from always-different addresses and domains The sender changes domain every day Block the server’s IP (step 3, «Refused connections»), not the domain
After refusing the domain a real customer gets no reply The domain was shared (a mass-mailing service) Remove the entry from «Refused senders» and use «Penalised senders»
An entry in «Refused senders» does nothing The same domain is in «Always accepted senders» Remove the entry from the accepted ones
«Never applied: this list compares the sender’s domain only.» You put an address in a domain list (earlier version) Remove the entry and, if needed, add the domain
The supplier still goes to spam after «Trust the sender’s domain» −7 or −2 are not enough Add «Trusted senders (SPF and DKIM)» or, as a last resort, «Always deliver»
«It is a public mail service» You tried to trust gmail.com or the like It is not done: the console refuses
Mail is delayed a few seconds after a change The Postfix lists restart the SMTP service Wait: the senders retry
Too much spam outbound or from your own domain A compromised account, or forgery of your domain In Mail → Logs → Traffic look at «Per-user daily sending»; for forgery of the domain raise the DMARC policy (A second mail domain and Mail)

Limits

  • The list scores (−7, −3, −2, −20, +8) are fixed: you choose the lists, not the numbers. There is no spam threshold to adjust in the console.
  • The lists belong to the appliance, not to the user: an entry applies to all recipients. There is no personal filter for Jack; each person can instead use their own mail rules in the webmail (Groupware).
  • An entry cannot be edited: it is removed and added again.
  • The Postfix lists restart the SMTP service at every change; do not make many in a row during peak hours.
  • Low-volume spam from senders that authenticate well is the hardest case: the filter cannot tell it from real mail, and only your decision (an entry in the lists) stops it.
LET’S TALK INFRASTRUCTURE

Control starts with a conversation.

Tell us about your infrastructure. Let’s start with what you actually need.

Talk to an engineer