summaryrefslogtreecommitdiff
path: root/home/mail/dovecot.sieve
blob: a0db18f8083abf3db5a0cf45ddf1c3efb1af059c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# Comando (pkgs.dovecot_pigeonhole) para filtrar mensajes existentes:
#
# $ sieve-filter -v -C -u alejandro@34project.org ~/.dovecot.sieve INBOX
#
# Ese comando es un dry-run, agregar "-W -e" para proceder. Probablemente es
# buena idea hacer 'snapshot -r' de ~/mail antes de ejecutar eso. El primer run
# tomó como 15 minutos para procesar todo el maildir.
#
# https://blog.bastelfreak.de/2020/08/dovecot-apply-sieve-filter-to-existing-emails/

require ["fileinto", "mailbox"];

if anyof(
  address :is "from" [
    "mailer-daemon@34project.org",
    "expiry@letsencrypt.org"
  ],

  address :is :localpart "to" ["abuse", "security", "postmaster", "hostmaster", "sysadmin"]
) {
  fileinto :create "admin";
} elsif address :is "from" ["notifications@github.com", "noreply@github.com"] {
  fileinto :create "github";
} elsif address :is "from" [ "lwn@lwn.net", "info@fsf.org"] {
  fileinto :create "news";
} elsif anyof(
  address :is "from" [
    "factura@factura.tigo.cr",
    "factura_electronica@claro.cr",
    "bcrtarjestcta@bancobcr.com",
    "mensajero@bancobcr.com"
  ],

  allof(
    address :is "from" "bncontacto@bncr.fi.cr",
    header :is "Subject" "Voucher Digital"
  ),

  allof(
    address :is "from" "support@ovh.ca",
    header :contains "Subject" ["Invoice available", "[INVOICE"]
  ),

  allof(
    address :is "from" [
      "support-renew@gandi.net",
      "support-es@gandi.net",
      "support-en@support.gandi.net"
    ],

    header :contains "Subject" ["Automatic crediting", "Factura", "domain name renewed"]
  ),

  header :is "From" "Recibos de Uber <noreply@uber.com>",
  address :matches "from" "cobros*@tigo.co.cr"
) {
  fileinto :create "bills";
# Esta es otra sección de .admin, existe para darle precedencia a recibos de OVH en .bills
} elsif address :is :domain "from" "ovh.ca" {
  fileinto :create "admin";
} elsif address :is :domain ["from", "to"] ["estudiantec.cr", "itcr.ac.cr", "tec.ac.cr"] {
  if allof(
    address :matches :localpart "from" "tecdigital*",
    # A veces han destruido la codificación de la tilde
    header :matches "Subject" "Notificaci*n de Documentos"
  ) {
    fileinto :create "tec.docs";
  } elsif anyof(
    address :is :localpart "from" "lcortes",

    allof(
      address :matches :localpart "from" "tecdigital*",
      header :contains "Subject" [
        "Estudiantes IDC - ",
        "Ingenieria En Computadores - ",
        "[ESTUDIANTES IDC]",
        "[AREA DE INGENIERIA EN COMPUTADORAS]"
      ]
    )
  ) {
    fileinto :create "tec.ce";
  } else {
    fileinto :create "tec";
  }
} elsif anyof(
  address :is :domain "from" [
    "turing.com",
    "turing.bz",
    "paypal.com",
    "mail.paypal.com"
  ],

  address :is "from" [
    "info@tigo.co.cr",
    "info@info.tigo.cr",
    "campaigns@fsf.org",
    "bcrsistematica@bancobcr.com"
  ],

  allof(
    address :is "from" "no-reply@github.com",
    header :contains "X-Mailer" "Mailchimp Mailer"
  ),

  allof(
    address :is "from" "no-reply@accounts.google.com",
    header :contains "Subject" "Alerta de seguridad"
  ),

  header :is "From" "The Google Account Team <google-noreply@google.com>"
) {
  fileinto :create "spam";
}