welcome: please sign in

The following 448 words could not be found in the dictionary of 7 words (including 7 LocalSpellingWords) and are highlighted below:
able   above   absolute   actually   Adam   adding   address   addresses   admin   ado   advanced   afs   after   alias   aliases   all   allof   allows   also   although   Always   an   and   Any   any   anyone   anything   are   articles   as   at   At   attempt   automatic   back   bandwidth   barackobama   base   based   Bayes   bcc   be   before   begins   below   Björn   bkhl   Board   board   boards   bogus   bounce   built   but   By   Bynum   can   Category   cause   Causes   cc   ch   Changed   changes   Chlipala   client   com   comment   community   complicated   consisting   consumer   contain   contains   Contents   Coop   Create   create   current   custom   cycles   daemon   daily   dang   def   default   deliver   delivered   Delivering   delivery   dev   different   directory   discuss   disk   disposed   do   doc   does   doesn   doing   domain   domains   Drops   due   each   easier   elif   else   elsewhere   elsif   email   endif   error   example   Examples   examples   Exim   exim   existing   explains   explanation   explicitly   expressions   facing   fanac   fancy   fandom   Fandom   fastmail   file   fileinto   files   filing   filter   Filter   Filtering   filtering   filters   Finally   finds   finish   flag   Flag   Floss   folder   folders   following   follows   For   for   fortunately   forward   forwarded   found   Frank   from   further   Generated   gets   Git   give   go   goes   good   groups   guide   ham   hard   has   have   hcoop   Hcoop   He   he   header   help   Here   his   hnreplies   home   how   However   howto   html   http   https   Hub   identical   identifying   ietf   if   If   immediately   implicit   important   in   In   inbox   including   instead   instructions   into   Introduction   is   it   It   its   itself   January   Junk   just   keep   Kennedy   knowledge   Launchpad   learned   less   Lessons   lets   level   Level   light   Lindström   line   lines   list   lists   liu   ll   log   logfile   logs   lot   lutris   Lutris   lysator   mail   Mail   Maildir   make   Make   making   Manual   matches   me   mean   Member   mentioned   message   messages   Michel   moderator   more   Most   much   must   my   Nathan   Needs   net   new   no   Normally   not   notifications   null   Obama   Of   of   off   on   one   ones   only   opinion   options   or   ordinary   org   other   our   out   over   own   page   parsing   path   people   per   picking   pipermail   point   possible   powerful   prevent   privacy   private   Probably   process   project   Proton   protonmail   public   Puts   Putting   quick   rather   re   reaches   reading   really   regular   relatively   relax   Removed   Reply   require   rest   rfc   rfc5228   rules   run   sala   salafandom   same   saner   save   say   score   scores   script   se   searching   section   seems   seen   send   sent   separate   set   setting   setup   should   sieve   Sieve   simply   slightly   sm   smichel17   snowdrift   So   so   Some   some   sort   space   Spam   spam   spambots   spamlog   spec   special   standard   start   starting   Status   Stephen   stop   store   stored   straight   style   sub   subfolder   subject   subscribe   suck   support   surprisingly   syntax   system   Table   technical   template   test   than   that   The   the   them   then   there   these   things   this   This   time   to   To   too   tools   treat   Trello   trick   two   type   undef   understand   up   upp   use   useful   user   username   using   values   various   Virtually   want   waste   way   We   we   website   were   what   When   when   where   whereas   which   while   wiki   will   wimpy   with   within   Without   work   Work   write   www   You   you   Your   your   yourself  

Clear message
Edit

MemberManual / Email / EximFilter

This page explains how to use Exim's built-in per-user filtering system to sort your mail into different folders or deliver it elsewhere.

Introduction

We use Exim as our mail daemon. It has a built-in filtering system that allows people to write a ".forward file" to give it custom instructions. Normally this is stored at ~/.forward, but at HCoop we store it at ~/.public/.forward to make it easier to keep the rest of your home directory private. So when we say ".forward" on the rest of this page, we mean ~/.public/.forward.

When email is delivered, the delivery process will run as the USER.daemon user, where USER is your HCoop username.

Delivering all mail to a different address

If you want email sent to your HCoop email address to be forwarded elsewhere, you can do that as follows.

(This is a standard UNIX .forward file.)

Putting mail into separate folders

For anything more complicated, you have two options: sieve and exim filters. In StephenMichel's opinion, sieve filters have the saner syntax, although exim filters are slightly more powerful. To use them, start your .public/.forward file with one of these special lines for identifying the type of filter:

The line above is not an ordinary comment. Any other values will cause Exim to attempt to treat the file as a list of forward addresses instead of a filter file.

Create folders before adding rules for them. Exim is not able to create new folders, only sort mail into existing ones. You should create and subscribe to any folders mentioned in these filters from within your IMAP client before adding them to your filter.

Sieve Filter Examples

StephenMichel

Lessons learned the hard way

  • If your script has a syntax error, and parsing reaches that point in the script, mail will simply not be delivered. Always send yourself a test email after making changes.

  • Probably due to our AFS setup, the only filing syntax that seems to work is fileinto, using an absolute path. keep does not work, including automatic/implicit keep, so you must explicitly fileinto your inbox.

  • If you just want quick examples, use the section below, fastmail's guide, or ProtonMail's guide. However, if you want to actually understand what you're doing & what's possible, all the various articles out there really suck; fortunately (and surprisingly) rfc 5228 itself is relatively light reading and you'll save yourself a lot of time starting there instead of searching for a more "consumer-facing" explanation.

This is my current filter, with two changes:

# Sieve filter

require ["fileinto"]; 

if address :contains ["to", "cc", "bcc"] ["admin@example.com", "community@example.com", "privacy@example.com"] {
    fileinto "/afs/hcoop.net/user/s/sm/smichel17/Maildir/.snowdrift.aliases/";
}
elsif address :contains :domain "to" "lists.example.com" {
    fileinto "/afs/hcoop.net/user/s/sm/smichel17/Maildir/.hcoop/";
}
# elsif address :matches ["to", "cc", "bcc"] ["snowdrift@example.com", "snowdrift+*@example.com"] {
#     fileinto "/afs/hcoop.net/user/s/sm/smichel17/Maildir/.snowdrift/";
# }
elsif address :contains ["to", "from", "cc", "bcc"] "board@example.com" {
    fileinto "/afs/hcoop.net/user/s/sm/smichel17/Maildir/.Board/";
}
elsif address :contains "from" "notifications@example.com" {
    fileinto "/afs/hcoop.net/user/s/sm/smichel17/Maildir/.notifications.GitHub/";
}
elsif header :matches "Reply-To" "*@boards.example.com" {
    fileinto "/afs/hcoop.net/user/s/sm/smichel17/Maildir/.notifications.Trello/";
}
elsif address :contains "to" "hnreplies.com@example.com" {
    fileinto "/afs/hcoop.net/user/s/sm/smichel17/Maildir/.notifications.HN/";
}
elsif allof (
    address :contains "from" "admin@example.com",
    header :contains "subject" "[Lutris]  Your daily moderator mail"
) {
    fileinto "/afs/hcoop.net/user/s/sm/smichel17/Maildir/.lutris/";
}
else {
    fileinto "/afs/hcoop.net/user/s/sm/smichel17/Maildir/";
}
stop;

Exim Filter Examples

The exim project website has some good examples http://www.exim.org/exim-html-current/doc/html/spec_html/filter_ch-exim_filter_files.html.

We also have example .public.forward files in the following section.

NathanKennedy

It is possible to set up custom filters to do fancy things based on the X-Spam-Level: header. Here is NathanKennedy's ~/.public/.forward file. He finds that the default setting of 5.0 is too wimpy, and lets too much spam into his inbox. Virtually no ham that he gets scores less than 3.0, whereas a lot of spam scores less than 5.0, so he'd rather have anything over 3.0 go to his Junk folder. At the same time, he doesn't want to waste time, cycles, disk space or bandwidth with spam over 9.0. Most of his spam does score 9.0, and this goes straight to /dev/null (immediately disposed of) with this filter.

Finally, he has all HCoop list email go into a special HCoop folder.

Without further ado:

# Exim filter
logfile $home/.logs/mail/spamlog
if $header_subject contains "[HCoop"
then
    save $home/Maildir/.HCoop/
    finish
endif
if
    "${if def:h_X-Spam-Level {def}{undef}}" is "def"
then
    if $h_X-Spam-Level: begins "\*\*\*\*\*\*\*\*\*"
    then save "/dev/null" 660
    else
      if $h_X-Spam-Level: begins "\*\*\*"
      then save $home/Maildir/.Junk/
      endif
    endif
    finish
endif
if
    "${if def:h_X-Spam-Flag {def}{undef}}" is "def"
then
    save $home/Maildir/.Junk/
    finish
endif

FrankBynum

# Exim filter
# Lists
if $h_to: contains "lists.hcoop.net"
        then save $home/Maildir/.Causes.Hcoop/
elif $h_to: contains "groups.barackobama.com"
        then save $home/Maildir/.Causes.Obama/
elif $h_X-Generated-By: CONTAINS "Launchpad"
        then save $home/Maildir/.Causes.Floss/
# Junk
elif $h_X-Spam-Level: begins "\*\*\*\*\*\*\*\*\*"
        then save "/dev/null" 660
elif $h_X-Spam-Level: begins "\*\*\*\*"
        then save $home/Maildir/.Junk.Spam/
elif $h_X-Spam-Status: contains "BAYES_99"
        then save $home/Maildir/.Junk.Bayes_99/
endif

StephenMichel

This template filters anything sent to me@example.com or to me+$anything@example.com into the sub-folder me. This is useful if you have one or more aliases set up, to filter mail for each alias into its own subfolder.

if "$h_to:, $h_cc:, $h_bcc:" matches "me(\\\\+[\\^@]\\*)\\?@example\\\\.com"
        then save $home/Maildir/.me/
endif

Björn Lindström

Some rules using matches which allows PCRE style regular expressions.

# Exim filter

# Log
logfile $home/.logs/mail/exim.log

# Don't do any filtering on delivery failure messages from Exim.
if error_message then finish endif

# Spam
if "${if def:h_X-Spam-Level {def}{undef}}" is "def" then
    # Drops mail with a spam level above 9
    if $h_X-Spam-Level: matches "^\\\\*{9}" then
        seen
        finish
    # Puts other mail with a spam level above 3 into "Spam"
    elif $h_X-Spam-Level: matches "^\\\\*{3}" then
        save $home/Maildir/.Spam/
        finish
    endif
elif "${if def:h_X-Spam-Flag {def}{undef}}" is "def" then
    # Puts other mail with spam flag set into "Spam" also.
    save $home/Maildir/.Spam/
    finish
endif

# Filter into folders
if "$h_to:, $h_cc:, $h_bcc:" matches "\\\\b((bkhl|upp?sala|relax)@fandom\\\\.se|upp?salafandom@dang\\\\.se|fanac@lists\\\\.lysator\\\\.liu\\\\.se)\\\\b" then
    save $home/Maildir/.Fandom/
elif "$h_to:, $h_cc:, $h_bcc:" matches "@(\\.*\\\\.)?hcoop\\\\.net\\\\b" then
    save $home/Maildir/.HCoop/
endif

Filtering out bogus bounce messages

AdamChlipala found a trick a while back that allows you to filter out bogus bounce messages. https://lists.hcoop.net/pipermail/hcoop-discuss/2007-January/000745.html


CategoryMemberManual CategoryNeedsWork

MemberManual/Email/EximFilter (last edited 2020-09-03 21:58:33 by StephenMichel)