Logo Security and Coding Explosive Tutorials Steffen Lippke

Block Spam Mail – The 8 Best Methods + Tutorial 2024

Block Spam Mails - Hacking Series Tutorial Steffen Lippke

You want to block spam mail?

I’ll explain you all the possibilities to get rid of the annoying mails.

Let’s get started!

What is Spam? What is Ham?

Authentische Mail - leider bin ich keine Kunde ...
Authentic mail – unfortunately I’m not a customer …

Spam e-mails are annoying:

Between advertising offers, malware mails and guaranteed gambling winnings (spam), the important, genuine e-mails (ham) cavort.

Spam is everywhere.

In the old days, when you went to your mailbox, the bad guys had to print out the contents and drop them in your mailbox.

Nowadays, a single server can send 1000s of emails per hour. Some idiot clicks on the link, transfers $10,000 for the fake investment and the money is gone. The criminals can improve their weapons and more spam mails start to circulate – a vicious circle.

The word spam comes from an American canned sausage product depicted in a Monty Python sketch as annoying, commonplace, oversaturated food.

Problem with mail addresses – Databreaches

Most spam is created by criminals hacking companies and stealing the mail addresses. This allows them to send targeted spam messages to users for fraud.

Have I been Pawned? - Viele Databreaches der Vergangenheit
Have I been Pawned? – Many Databreaches of the Past

While passwords are protected with hash methods, personal data such as emails are unprotected in the event of a breach. Better IT security and extensive pentesting is the solution.

Comparison of solutions

You have several options to protect yourself from spam:

#1 Most effective solution – Whitelist

The most effective solution is to whitelist all contacts from whom you expect to receive mail.

Whitelist in Thunderbird
Whitelist in Thunderbird

This method is very good if you create an account only for personal and interpersonal communication. In the case of online service notifications, you usually do not know which e-mail address is writing to you.

Nevertheless, you should be in possession of a mail address which you only pass on to your real friends.

#2 Practical solution – Mail Relay

A whitelist does not solve the databreach problem – but a mail relay does.

You can enter a new mail address every time you register. For a Google mail you can always type a plus with a random text. From vorname.nachnahme@gmail.com you can make a firstname.lastname+amazon@gmail. This relay only works with the dumbest spam bots. If you want to do it right, you need a real relay.

Mozilla bietet ein Relay als Fremium an
Mozilla offers a relay as a Fremium

An email relay generates one email address per service. You have different mail addresses for shop A and shop B. The relay forwards these to your main mail address. The relay forwards these to your main address. If criminals infiltrate Shop A and send spam to Mail A, you can switch them off. If you want to order something from shop A again, you should change the mail address after the breach.

#4 Secret Mail

The secret mail works like the whitelist – the only change is that it is cryptic and is difficult guess. If you email elon.musk@tesla.com, it should not reach Elon. CEOs use secret email addresses like k2hsd924lasdfj2ha@telsa.com to prevent anyone from giving away the email address

What types of spam filters are there?

The classic spam solution is the spam filter. Spam fitters are static, dynamic or equipped with NLP. Often you will not find a pure form, but a mixture.

#6 Static

Simple rule like:

– reject all mails from“spamschleuder@example.com”

– reject all mails with the content “You have won” … are static filters

… are static filters. Clear rules tell the software which mails pass through the filter.

#7 Dynamic

If 50 users mark the same mail as spam, the filter updates itself automatically and does not let this mail through to other mail users.

Steffen Lippke

Because spam mails often come in waves, the filters can work effectively. This form of filter is based on training data and the cooperation of many email readers. The spam must first be sorted manually, so that with every other mailbox, the filtering takes place automatically.

#8 Artificial Intelligence

Neural networks are good at classifying new content without understanding the content of the message. If you have a large collection of spam and “real mail”, the neural network can configure itself to sort out the spam.

Machine Larning is Key
Machine learning is key

The better you have sorted out spam mails, the better the neural network can work. The software looks at the most important keywords:

  • Confirmation, demand, order process, birthday → Words that mostly appear in real mails
  • Profit, Utra discount, inheritance, FED transfer → Words that occur frequently in spam mails

The software crosses out all filler words such as a, a, to, am, through and so on and examines the interesting words. This system has its limitations because a ‘benign’ email can also be worded like a spam email. Furthermore, such a filter does not help against spearphisihing.

Setting up spam filters

Most mail providers have a spam filter activated by default on most accounts. Because the mail providers take care of the delivery to several accounts, you have an even more global view. If the provider has to deliver 30,000 mails from the same unknown mail address to 30,000 mailboxes, the provider will reject the mail directly.

Activate your individual spam filter in the settings of your e-mail provider.

In most cases, this filter is “OK”. Only if the spam filter always sorts the mails incorrectly over months, you should switch it off and try variant 2.

Some mail providers allow you to set a sensitivity. If you suffer from heavy spam infestation, you can set the sensitivity high. You will have to adjust this fine-tuning again and again over weeks and months.

Variant 2 – Local filtering

If the spam filter of your mail provider is not usable, use the Thunderbird spam filter.

Install the Thunderbird mail program locally on your computer (Windows, Linux, macOS) and link the program to your account. Thunderbird automatically sets up the known providers such as T-online or Gmail. If you use a special provider, you need the IMAP and SMTP URL and port. Most providers transmit the e-mails in encrypted form.

Spam in Thunderbird
Spam in Thunderbird

Thunderbird automatically evaluates incoming mails. Click on the email in the left bar > Settings > Junk Settings. The check mark for adaptive junk control should always be active. The program learns faster if you mark spam mails as spam and do not delete them.

Thunderbird does not move mails to spam if you have saved them in your address book (whitelist).

Newsletter writers use the “spam headers” of commercial providers so that delivery is guaranteed. Often newsletter writers have the problem that a spam filter sorts out their mails. Many filters cannot distinguish real discount promotions, purchase links and real competitions from fakes.

Thunderbird has disabled this option because criminals can also buy these spam headers. Manually set where Thunderbird sends the spam. A folder titled Spam is the best place for it. Junk mail are real offers from companies, but you consider them useless


Jeden Monat teile ich mit Mitgliedern
4 neue praxisnahe Tutorials (je 1000+ Wörter).


Trage Deine Mail, damit Du
Deine Coding + Hacking Skills erweitern kannst!

Die Webseite nutzt nur technisch notwendige Cookies.