summaryrefslogtreecommitdiff
path: root/.imapfilter/config.lua
blob: 4f101e358a3026261051b876f09bc9a868824e9e (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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
-- The time in seconds for the program to wait for a mail server's response (default 60)
options.timeout = 120

-- According to the IMAP specification, when trying to write a message to a
-- non-existent mailbox, the server must send a hint to the client, whether
-- it should create the mailbox and try again or not. However some IMAP
-- servers don't follow the specification and don't send the correct
-- response code to the client. By enabling this option the client tries to
-- create the mailbox, despite of the server's response.
options.create = true

-- By enabling this option new mailboxes that were automatically created,
-- get also subscribed; they are set active in order for IMAP clients to
-- recognize them
options.subscribe = true

-- Normally, messages are marked for deletion and are actually deleted when
-- the mailbox is closed. When this option is enabled, messages are
-- expunged immediately after being marked deleted.
options.expunge = true

options.starttls = true

options.hostnames = false

-- Escapes problematic characters in passwords.
function sanitize_pwd(pwd)
	-- Chomp off newline character that is sucked in from Password Store.
	pwd = string.gsub(pwd, "\n", "")

	-- Escape backslash characters that exist in passwords. Need to escape the
	-- escape characters at each 'level' where the password string is used
	-- otherwise escape characters are lost.
	--
	-- The slashes are escaped first. If they were escaped later then
	-- characters escaped later would be escaped again.
	pwd = string.gsub(pwd, '%\\', '\\\\')

	-- Escape double quote characters that exist in passwords.
	pwd = string.gsub(pwd, '%"', '\\"')

	return pwd
end

-- Gets password from pass
--status, password_suse = "testtest"
status, password_suse = pipe_from("pass show suse/imap_password")
status, password_mailbox = pipe_from("pass show mailbox.org/pass")

local suse = IMAP {
	server = "imap.suse.de",
	username = "bdas@mutt",
	password = sanitize_pwd(password_suse),
	ssl = "ssl3"
}

local mailbox = IMAP {
	server = "imap.mailbox.org",
	username = "listout@mailbox.org",
	password = sanitize_pwd(password_mailbox),
	ssl = "ssl3"
}

local dmarc_listout = mailbox.INBOX:contain_subject("Report Domain: listout.xyz")
dmarc_listout:move_messages(mailbox["dmarc_reports"])

local kernel_mentees = mailbox.INBOX:contain_cc("linux-kernel-mentees@lists.linux.dev") +
						mailbox.INBOX:contain_to("linux-kernel-mentees@lists.linux.dev") +
						mailbox.INBOX:contain_from("linux-kernel-mentees@lists.linux.dev")
kernel_mentees:move_messages(mailbox["linux-kernel-mentees"])

kernel_mentees = mailbox.INBOX:contain_cc("linux-kernel-mentees@lists.linuxfoundation.org") +
						mailbox.INBOX:contain_to("linux-kernel-mentees@lists.linuxfoundation.org") +
						mailbox.INBOX:contain_from("linux-kernel-mentees@lists.linuxfoundation.org")
kernel_mentees:move_messages(mailbox["linux-kernel-mentees"])

local kernel_stable = mailbox.INBOX:contain_cc("stable@kernel.org") +
						mailbox.INBOX:contain_to("stable@kernel.org") +
						mailbox.INBOX:contain_from("stable@kernel.org")
kernel_stable:move_messages(mailbox["kernel-stable"])

kernel_stable = mailbox.INBOX:contain_cc("stable@vger.kernel.org") +
						mailbox.INBOX:contain_to("stable@vger.kernel.org") +
						mailbox.INBOX:contain_from("stable@vger.kernel.org")
kernel_stable:move_messages(mailbox["kernel-stable"])

local kernel_harden = mailbox.INBOX:contain_cc("linux-hardening@vger.kernel.org") +
						mailbox.INBOX:contain_to("linux-hardening@vger.kernel.org") +
						mailbox.INBOX:contain_from("linux-hardening@vger.kernel.org")
kernel_harden:move_messages(mailbox["kernel-harden"])

kernel_harden = mailbox.INBOX:contain_cc("linux-hardening@kernel.org") +
						mailbox.INBOX:contain_to("linux-hardening@kernel.org") +
						mailbox.INBOX:contain_from("linux-hardening@kernel.org")
kernel_harden:move_messages(mailbox["kernel-harden"])

local gentoo_dev = mailbox.INBOX:contain_cc("lists.gentoo.org") +
					mailbox.INBOX:contain_to("lists.gentoo.org") +
					mailbox.INBOX:contain_from("lists.gentoo.org")
gentoo_dev:move_messages(mailbox["gentoo-dev"])

--suse.INBOX:check_status()

-- Solid Ground
local sg = suse.INBOX:contain_from("sg_noreply@suse.de")
sg:move_messages(suse["sg"])

-- DL APAC news
local dl_su_apac = suse.INBOX:contain_cc("DL-SU-APAC@suse.com") +
	suse.INBOX:contain_to("DL-SU-APAC@suse.com") +
	suse.INBOX:contain_from("DL-SU-APAC@suse.com")
dl_su_apac:move_messages(suse["DL-SU-APAC"])

-- DL india news
local dl_su_india = suse.INBOX:contain_cc("dl-su-india@suse.com") +
	suse.INBOX:contain_to("dl-su-india@suse.com") +
	suse.INBOX:contain_from("dl-su-india@suse.com")
dl_su_india:move_messages(suse["DL-SU-INDIA"])
dl_su_india = suse.INBOX:contain_to("dl-su-india@suse.com")
dl_su_india:move_messages(suse["DL-SU-INDIA"])

-- l3-coord
local l3_cord = suse.INBOX:contain_from("l3-coord@suse.de") + suse.INBOX:contain_cc("l3-coord@suse.de") +
	suse.INBOX:contain_to("l3-coord@suse.de") + suse.INBOX:contain_cc("critsit@suse.de")
l3_cord:move_messages(suse["l3-coord"])

-- bugzilla incoming emails
local bg = suse.INBOX:contain_cc("bugzilla_noreply@suse.com") + suse.INBOX:contain_from("bugzilla_noreply@suse.com")
bg:move_messages(suse["bg_replies"])

-- kernel suse mailing list
local kernel_suse = suse.INBOX:contain_cc("kernel@suse.de") + suse.INBOX:contain_to("kernel@suse.de") +
	suse.INBOX:contain_from("kernel@suse.de")
kernel_suse:move_messages(suse["kernel-suse"])

-- Incoming messages from kbuild
local kbuild = suse.INBOX:contain_from("kbuild@suse.de")
kbuild:move_messages(suse["kbuild"])

-- sdi mailing list
local sdi = suse.INBOX:contain_from("sdi-team@suse.de") + suse.INBOX:contain_cc("sdi-team@suse.de") +
	suse.INBOX:contain_to("sdi-team@suse.de")
sdi:move_messages(suse["sdi-team"])

-- devel mailing list
local devel = suse.INBOX:contain_cc("devel@suse.de") + suse.INBOX:contain_to("devel@suse.de")
devel:move_messages(suse["devel"])

-- Advert from OReilly, LinkedIn and Lenovo
local advert = suse.INBOX:contain_from("oreilly") + suse.INBOX:contain_from("lenovo") +
	suse.INBOX:contain_from("linkedin")
advert:move_messages(suse["advert"])

-- DL linux all news
local dl_linux_all = suse.INBOX:contain_to("dl-linux-all@suse.com") + suse.INBOX:contain_cc("dl-linux-all@suse.com") +
	suse.INBOX:contain_from("dl-linux-all@suse.com")
dl_linux_all:move_messages(suse["dl_linux_all"])

-- BCL news
local bcl_news = suse.INBOX:contain_body("BCL Monthly Newsletter") + suse.INBOX:contain_subject("BCL Monthly Newsletter")
bcl_news:move_messages(suse["bcl_news_letter"])

-- HR and pay slip notification
local hr_noreply = suse.INBOX:contain_from("no-reply@greythr.com")
hr_noreply:move_messages(suse["hr_noreply"])

-- jira notifications
local jira = suse.INBOX:contain_from("jira-sd@suse.com") + suse.INBOX:contain_from("jira@suse.com")
jira:move_messages(suse["jira"])

-- klp patches mailing list
local klp_patches = suse.INBOX:contain_cc("klp-patches@suse.de") + suse.INBOX:contain_to("klp-patches@suse.de") +
	suse.INBOX:contain_from("klp-patches@suse.de")
klp_patches:move_messages(suse["klp-patches"])

-- Meeting invitaions
local invitaions = suse.INBOX:contain_subject("Invitation:")
invitaions:move_messages(suse["meeting invitaions"])

-- autobuild
local autobuild = suse.INBOX:contain_from("autobuild@suse.de")
autobuild:move_messages(suse["autobuild"])