lcmail-wizard - procmail rules and auto trash script

Matteo Zeccoli Marazzini 398d4b10da Add Debian and Centos directories 2 years ago
log 93f617a9a7 Add log dir, and ignore *.log* files 3 years ago
.forward 12eb5d860d Add default config files 3 years ago
.gitignore 93f617a9a7 Add log dir, and ignore *.log* files 3 years ago
.procmailrc 12eb5d860d Add default config files 3 years ago
Makefile 5bea23f330 Add hostname env 2 years ago
README.md f620a20dd2 Update README 2 years ago
filter-rules.def.rc f97f4fa929 Remove overkill whitelists 2 years ago
lcmail-wizard.def.cron 45912c47f9 Modify cron default, and cron creation, add more backup/restore feats 3 years ago
lcmail-wizard.def.yml 398d4b10da Add Debian and Centos directories 2 years ago
lcmail-wizard.py d42a59c8a8 Add --create flag 3 years ago

README.md

lcmail-wizard :mailbox:

:blue_book: Description

The aim of these repo is try to facilitate new admins or 150hs to be procmail users using only LCM services to handle mails

  • Are you an admin or staff member of LCM?

    If yes, sooner or later your LCM user will be added to some or (in the worst case) all mailing lists of LCM

    If no, why are you visiting this site? Get out of here!

  • What does it mean?

    It means you will be flooded with mails every date! And yes, you can't follow the strategy INBOX for all, beacuse part of your work is to pay attention to these mails: check, reply, or even archive them

  • So what is the strategy that is usually recommended?

    For now (pre zimbra deploy), there are 2 possibilities, depending on the content of your ~/.forward you can decide to be:

    • a spam forwarder + G-slave, forwarding all your LCM mail traffic (spam included) to an external mail account (that usually permit you to make filter rules easily using webUI, e.g. Gmail)

      $ cat ~/.forward
      nomeutentelcm
      nomeutentelcm@gmail.com
      

    Pros:

    • Easy filter rules management
    • More space for mails

      Against:

      • Increase the probability to blacklist pcteor1, because (in this way) is considered the source of spam
      • Depend on external proprietary service
      • Not use self-hosted LCM services, e.g. LCM webmail
      • Little delay in mail delivery
      • Pay attention also to your ~/.maildir, that can increase significantly (LCM home quota is 1G max)
    • a procmail user, so use procmail to filter out during the delivery to local ~/.maildir the mails

      $ cat ~/.forward
      "|IFS=' '&&exec /usr/bin/procmail -f-||exit 75"
      

      Pros:

      • Learn something new
      • Know and use all the services self-hosted by LCM (dovecot [imap], roundcube [webmail], postfix [smtp])
      • Hackable filter rule system

      Against:

      • Less space available
      • Time consuming configuration
      • The procmail conf needs a bit of run-in and control to understand that everything is handled correctly

:star: Features

  • Very useful for IMAP + webmail workflow
  • Auto trash script
  • Custom configuration from a template for auto-trashing and filtering
  • Easy setup or restore using make

:rocket: Setup

  • Default setup

    $ make install
    
  • Custom setup

    $ make init
    

    Read and edit configuration files:

    • filter-rules.rc

      Copy of my procmail filter rules (filter-rules.def.rc), the file is already commented, the key idea is to filter using mail headers (^From:, ^To:, ^Subject:) and delivery to custom folder. The ~/.maildir/. folder structure must be something like that:

      .maildir/
      ├── cur -> INBOX - read mails
      ├── new -> INBOX - unread mails
      ├── tmp
      ├──  .Admins
      │   ├── cur
      │   ├── new
      │   └── tmp
      ├── .Archive
      │   ├── cur
      │   ├── new
      │   └── tmp
      |
      .
      .
      .
      |
      └── .Trash
          ├── cur
          ├── new
          └── tmp
      

      You don't have to worry about replicating it manually, because lcmail-wizard.py -c do it for you parsing dirs from lcmail-wizard.yml, but pay attention, the automation it's only on install!

      So if you decide to delete some dirs inside lcmail-wizard.yml (and so change as consequence filter-rules.rc), you can do here, before make install, and installation wil act as you expect. But when lcmail-wizard has already been installed, adding or removing dirs inside lcmail-wizard.yml not update anything inside ~/.maildir/ (for safety)

    • lcmail-wizard.yml

      YAML configuration file, divided in two list mail an log (procmail and lcmail-wizard.py log)

      For mail the meaning of the integers are the number of days to wait from the reading date before trash a mail (so number of days to wait after mail is moved inside *./cur to trash it). So no mails are trashed if not read! And no mail are completly delete (removed from trash) without your interaction

      There is an exception, the 0 has special meaning, it means no expiration, don't throw any mail, even if read

      For log the same thing, but simply on creation date (no meaning here read or not read)

    • lcmail-wizard.cron

      Simple cron file, to schedule lcmail-wizard.py script

      Pay attention, mark on which LCM node you schedule the script (where you run make install) e.g. pang, beacuse in case of node fail, lcmail-wizard.py script won't execute. And in case of uninstall (see Makefile) you need to be on the same node to stop schedule

      $ make install
      

:dart: Sum up

Take home messages:

  • don't be a spam-forwarder, be procmail user

  • if you decide to modify the lcmail-wizard.yml dir list (so as consequence also the filter-rules.rc) before install you are ok

  • if you decide to modify the lcmail-wizard.yml dir list (so as consequence also the filter-rules.rc) after install you are not ok, you have to ensure that the proper directory structure exists inside ~/.maildir (if not exists you have to procede manually)

  • if you decide to modify the lcmail-wizard.yml expiration date integer you are ok before, after and on run

  • if you decide to create new custom rules before, after on run, remember always to ensure that the proper directory structure exists inside ~/.maildir (if not exists you have to procede manually), otherwise mail delivery will fail. And to insert (or remove) destinations also inside lcmail-wizard.yml if you want auto-trashing. In few words take sync beetween ~/maildir tree and lcmail-wizard.yml maildir list

  • run make uninstall one the same installation node, beacause make install create cronjob on the particolar node

  • my personal workflow is IMAP to fetch mails and get notification on mobile, and if I need to write or answer a mail I use the LCM webmail on laptop. The configuration of webmail is very simple:

    login > Gear symbol (below) > Manage folders > Enable folders you want > Happy filtering :stuck_out_tongue_winking_eye:

    Last advice in webmail, enable "Empty trash on logout"

    login > Settings (above) > Preferences > Server settings > Clear Trash on logout > Save