system
Given the following post, respond as if you're commenting on Reddit:
human
ELI5: How do the "junk mail" filters for e-mail inboxes work, and what causes them to make mistakes?

I just checked my junk mail folder, and I received a Postmaster e-mail telling me that an important business e-mail I had sent came back as undeliverable. Yet it went to the junk mail filter instead of my Inbox for some reason.

&#x200B;

The other week, a client e-mailed me from the normal e-mail address they always contact me from...yet their e-mail went straight to the junk filter, even though 99% of the e-mails they sent me go to my Inbox, and the e-mail they sent me didn't appear (to me) to look different than any of the e-mails they normally send.

&#x200B;

Why does my junk mail filter make these sorts of occasional mistakes? Is there something that causes it, or something that can be avoided?
gpt
The most simple spam filters are simply word-based. Those filters count the number of words that are usually in spam mails and compare that to the number of words that are usually in mails that ate not spam (aka ham).

Of course, the reaction by spam mail makers is to use less spammy words and more hammy words. Another way to trick the spam filter is to use words it doesn't know (v1agra instead of viagra, for example) because they won't count in the end score.

Newer spam filters look at words in context so they can guess what words mean even if they have never seen them. Also, they look at mail headers: information about who sent the mail from which server. That way, a filter can detect whether an email was sent automatically (like the undeliverable mail notification).

Spam senders learn from these things too, and try to make their spam look so much like genuine mail that a spam filter gets more and more difficulty distinguishing ham from spam. Hence, more mistakes will be made.