dovecot: deleting mails with find instead of doveadm expunge

This commit is contained in:
missytake 2023-12-14 15:01:26 +01:00
parent 049ed79e59
commit 070003b983
4 changed files with 13 additions and 33 deletions

View File

@ -17,8 +17,8 @@ max_user_send_per_minute = 60
# maximum mailbox size of a chatmail account
max_mailbox_size = 100M
# time after which mails are unconditionally deleted
delete_mails_after = 40d
# days after which mails are unconditionally deleted
delete_mails_after = 40
# minimum length a username must have
username_min_length = 9

View File

@ -1,4 +1,10 @@
2 0 * * * dovecot doveadm expunge -A SAVEDBEFORE {{ config.delete_mails_after }} MAILBOX INBOX
2 0 * * * dovecot doveadm expunge -A SAVEDBEFORE {{ config.delete_mails_after }} MAILBOX Deltachat
2 0 * * * dovecot doveadm expunge -A SAVEDBEFORE {{ config.delete_mails_after }} MAILBOX Trash
2 30 * * * dovecot doveadm purge -A
# delete all mails after {{ config.delete_mails_after }} days, in the Inbox
2 0 * * * dovecot find /home/vmail/mail/{{ config.mail_domain }}/*/cur -depth -mtime +{{ config.delete_mails_after }} -type f -delete
# or in any IMAP subfolder
2 0 * * * dovecot find /home/vmail/mail/{{ config.mail_domain }}/*/.*/cur -depth -mtime +{{ config.delete_mails_after }} -type f -delete
# even if they are unseen
2 0 * * * dovecot find /home/vmail/mail/{{ config.mail_domain }}/*/new -depth -mtime +{{ config.delete_mails_after }} -type f -delete
2 0 * * * dovecot find /home/vmail/mail/{{ config.mail_domain }}/*/.*/new -depth -mtime +{{ config.delete_mails_after }} -type f -delete
# or only temporary (but then they shouldn't be around after {{ config.delete_mails_after }} days anyway).
2 0 * * * dovecot find /home/vmail/mail/{{ config.mail_domain }}/*/tmp -depth -mtime +{{ config.delete_mails_after }} -type f -delete
2 0 * * * dovecot find /home/vmail/mail/{{ config.mail_domain }}/*/.*/tmp -depth -mtime +{{ config.delete_mails_after }} -type f -delete

View File

@ -36,29 +36,6 @@ def build_webpages(src_dir, build_dir, config):
print(traceback.format_exc())
def timespan_to_english(timespan):
val = int(timespan[:-1])
c = timespan[-1].lower()
match c:
case "y":
return f"{val} years"
case "m":
return f"{val} months"
case "w":
return f"{val} weeks"
case "d":
return f"{val} days"
case "h":
return f"{val} hours"
case "c":
return f"{val} seconds"
case _:
raise ValueError(
c
+ " is not a valid time unit. Try [y]ears, [w]eeks, [d]ays, or [h]ours"
)
def int_to_english(number):
if number >= 0 and number <= 12:
a = [
@ -104,9 +81,6 @@ def _build_webpages(src_dir, build_dir, config):
render_vars["password_min_length"] = int_to_english(
config.password_min_length
)
render_vars["delete_mails_after"] = timespan_to_english(
config.delete_mails_after
)
target = build_dir.joinpath(path.stem + ".html")
# recursive jinja2 rendering

View File

@ -42,7 +42,7 @@ The first login sets your password.
- You may send up to {{ config.max_user_send_per_minute }} messages per minute.
- Messages are unconditionally removed {{ delete_mails_after }} after arriving on the server
- Messages are unconditionally removed {{ config.delete_mails_after }} days after arriving on the server
- You can store up to [{{ config.max_mailbox_size }} messages on the server](https://delta.chat/en/help#what-happens-if-i-turn-on-delete-old-messages-from-server).