MAILFILTEREX(5)

πŸ’– MAILFILTEREX(5) πŸ’–

ok bestie, this is the file format descriptions page of the manual β€” specifically the MAILFILTEREX(5) one, aka the one with all the juicy examples. no cap. πŸ¦‹


✨ NAME ✨

mailfilterex β€” Mailfilter configuration file examples πŸŽ€


🌸 SYNOPSIS 🌸

$HOME/.mailfilterrc examples

πŸ’… DESCRIPTION πŸ’…

So like, if you want the actual rundown of the rcfile format and all its keywords, go read the mailfilterrc(5) man page instead. Orrr you can grab a basic starter set of options from either the INSTALL file or the doc/ directory of the Mailfilter distribution. both work, pick your fighter. πŸ’«

This man page right here? It's the fun one. It's literally a pile of configuration examples and real-life use cases for the Mailfilter program. so iconic of it. πŸ‘‘


πŸ”₯ EXAMPLES πŸ”₯

Heads up bestie: unless it says otherwise, every example below assumes you're using extended Regular Expressions, not Mailfilter's default, which is the basic type. Don't get caught out. πŸ’€

Wanna learn Regular Expressions in general? The regex(7) man page has you, or literally any good book on UNIX/POSIX. You could also take slightly modified examples from procmail(1) if it happens to be available on your system. slay, options. ✨


🚫 Filtering Domains 🚫

To build a very restrictive set of filter rules you should use at least two keywords: ALLOW and DENY. Picture this: DENY matches every message coming from some annoying public mail service, while ALLOW matches messages from a good friend who also uses that same annoying public mailer. the betrayal of it all 😭

DENY = "^From:.*public-mail\.com"
ALLOW = "^From:.*friend@public-mail\.com"

These two lines are enough to block everything but your friend's e-mail from the public-mail.com domain. periodt. πŸ’…


πŸŽ€ Case Sensivity πŸŽ€

In general, case-sensivity is controlled by the REG_CASE keyword. Having Mailfilter treat expressions as case-insensitive is almost always more efficient. fr fr. 🧚

REG_CASE = "no"
DENY = "^Subject:.*win money"

In this example Mailfilter would delete all messages with subject lines like WIN MONEY, Win Money or any other mix of capital and non-capital characters. REG_CASE makes filters ignore the case entirely. πŸ™ˆ

Now, a more complex setup can be achieved by additionally using the DENY_CASE keyword.

DENY_CASE = "^Subject:.*BUSINESS"

Here, only e-mails that have BUSINESS in their subject match the filter β€” even though in general Mailfilter ignores the case. So in this example, all messages with business or Business in their subjects would not be affected by this filter. sneaky but make it on purpose. 😌

Such an option is very useful if you're not interested in commercial bulk mail offering amazing business opportunities, but you are interested in all your actual business partners who contact you by e-mail. the way that distinction matters πŸ’œ


🫢 Defining Friends 🫢

The keyword ALLOW can be used to override any spam filters. Similar to the earlier example, ALLOW defines a friend.

ALLOW = "^Subject:.*mailfilter"

Adding this rule to the rcfile would mean all messages that contain anything about Mailfilter in their subject lines can pass the spam filters. iconic, protected, untouchable. πŸ‘‘

But even friends tend to send large e-mails sometimes, to share their joy about the latest joke that just made the round in their office. In such cases a limit can be defined that affects particularly friends.

MAXSIZE_ALLOW = 500000

Setting MAXSIZE_ALLOW to 500000 means no message can be larger than 500 kBytes. (Scanned office-jokes are usually around that size. we know. πŸ“)


πŸ™… Negative Message Filters πŸ™…

In order to create a very restrictive spam protection, it can sometimes be more useful to define which e-mails should not be deleted instantly, and consequently get rid of messages that can not be matched to this criterion β€” rather than the other way round. You do this by using negation. The typical use case is looking at the message tags To: or Cc: of an e-mail. πŸ‘€

DENY <> "^(To|Cc):.*my-email@address\.com"

Having added such a filter to your personal rule set keeps away a lot of spam that is not directly addressed to your e-mail account. Since this is a very aggressive way of filtering, you are well advised to keep your friends list up to date. lowkey essential. 🚨

Also note that the above example, using the logical OR operator, works only with extended Regular Expressions. don't say we didn't warn you bestie. πŸ’…

πŸ“Š Scores πŸ“Š

Instead of setting up spam filters, it's also possible to define scores which can be accumulated until a certain threshold is reached. This is very useful to delete advertisements on mailing lists, for instance. Highscore marks the threshold:

HIGHSCORE = 100
SCORE +100 = "^Subject:.*viagra"
SCORE +100 = "^Content-Type:.*html"
SCORE -100 = "^(To|From):.*my_mailing_list"

This simple example is useful to delete mails with a score greater than 100. i.e. if someone sends an HTML mail to my_mailing_list, the message will reach score 0. However, should an HTML mail regarding Viagra reach the list, then the message will classify as spam, because it reached an overall score of 100. math is math. πŸ”₯

The MAXSIZE_SCORE keyword can be used to add to the accumulated score for an e-mail. The following will cause all emails not directly addressed to the recipient and greater than 60000 bytes in size to be deleted (a useful way of rejecting many common MS targeted worms and trojans which can clog up your inbox). bye worms πŸ’€

HIGHSCORE = 100
MAXSIZE_SCORE +50 = 60000
SCORE +50 <> "^(To|Cc):.*my-email@address\.com"

This is a less aggressive way of dealing with e-mail sizes than using the MAXSIZE_DENY keyword.

Note that this example (by using the expression (To|Cc):.*my-email@address\.com) works only with extended Regular Expressions. again!! it's always the extended thing 😭

πŸ“ General Message Size Limits πŸ“

It is always a good idea to define a very general size limit for e-mails. Mailfilter uses the keyword MAXSIZE_DENY for that purpose.

MAXSIZE_DENY = 200000

Setting it to 200 kBytes can save you a couple of hours, depending on how much mail you get everyday. Messages bigger than that get deleted on the server, unless they match any of the ALLOW rules. To achieve maximum efficiency it makes sense to use both MAXSIZE_DENY and MAXSIZE_ALLOW. No one should block up your mail box, no friends, no others. not on your watch. 🫢

A rule of thumb is to be twice as tolerant towards friends than you are towards anonymous people. cute and fair. ✨


πŸ‘― Dealing with Duplicates πŸ‘―

Most people want to download a message only once, even though it might have been sent to two or three of their accounts at the same time. The simple line

DEL_DUPLICATES = "yes"

will take care of duplicates and makes sure that only one copy of a message has to be delivered. no more triple-sending trauma. πŸŽ€


🧼 Normalisation of Message Subjects 🧼

Every now and then some clever sales person comes up with the brilliant idea to wrap spam in funny little characters. If you get a message with a subject line similar to this one:

,L.E-G,A.L; ,C.A-B`L`E, .B-O`X`

then ordinary filters would fail to detect the junk. the audacity 😀

NORMAL = "yes"

Adding this directive to the rcfile tells Mailfilter to normalise subject strings, i.e. leave in only the alpha-numeric characters and delete the rest. That string up there would then become LEGAL CABLE BOX which can easily be matched to a spam filter. ate. πŸ’…

Note that Mailfilter first tries to match the original subject string, before it checks on the normalised one. order matters bestie. 🌸

πŸŽ›οΈ Control Mechanism πŸŽ›οΈ

Since Mailfilter deletes e-mails remotely, before they have to be downloaded into the local machine, it is also important to know what is going on while the program is being executed. The least you should do is define a proper level of verbosity and a log file. like, at minimum. πŸ™ˆ

LOGFILE = "$HOME/logs/mailfilter-`date +"%h%y"'"
VERBOSE = 3

Level 3 is the default verbosity level. Using it, Mailfilter reports information on deleted messages, run-time errors and dates to the screen and the log file. receipts everywhere, we love that. 🧾

You can use command to embed shell scripts into your path names. In the above example it is used to store log files separately for each month and year. organization is self-care. πŸ’œ


🌈 Extended Regular Expressions 🌈

For advanced applications, the basic Regular Expressions are typically not sufficient. If you know the syntax and usage of the extended expressions, it is almost always a good idea to set REG_TYPE accordingly.

REG_TYPE = "extended"

Extended expressions are more flexible, but also more sensitive towards syntax errors and the like.

Examples in this man page all use extended type. so if you copy-paste, you know what to set. πŸ’…

⭐ NOTES ⭐

If you are new to Regular Expressions and new to Mailfilter, you might want to experiment a bit, before you accidentally delete messages for real. scary!! 😭 For such cases Mailfilter provides two keywords. TEST can be used to only simulate the deletion of messages and SHOW_HEADERS stores all the e-mail headers that get examined by the program.

TEST = "yes"
SHOW_HEADERS = "$HOME/logs/mailfilter-headers.txt"

Use this setup if you are not yet comfortable with the concept of spam filtering. It may help to understand Regular Expressions better and how to use them. training arc era ✨


πŸ‘‘ SEE ALSO πŸ‘‘

mailfilter(1), mailfilterrc(5), procmailrc(5), procmailex(5), regex(7)


Copyright © 2000-2020 Andreas Bauer <baueran@gmail.com> 🫢

This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. (read that again. NO warranty. okay love u bye πŸ’…)


and that's the whole page bestie β€” brought to you by the Mailfilter manual, dated January 2009, living under the manual name MAILFILTEREX(5). go forth and filter, you've got this. πŸ¦‹βœ¨πŸŽ€

πŸ“¦ where this page comes from