From 74502b0c62b56df4b4b0e85f452a30a7ce9d45f1 Mon Sep 17 00:00:00 2001 From: Jonas Heinrich Date: Mon, 18 Aug 2025 16:22:47 +0200 Subject: [PATCH] add current threshold to warning mail --- mail-quota-warning.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mail-quota-warning.py b/mail-quota-warning.py index 08a4d2b..26fb045 100644 --- a/mail-quota-warning.py +++ b/mail-quota-warning.py @@ -181,7 +181,7 @@ def should_send_warning(state, account_name, interval_days): last_sent = datetime.fromisoformat(last_sent_str) return datetime.now() - last_sent >= timedelta(days=interval_days) -def send_warning(config, triggered_accounts, all_quotas): +def send_warning(config, triggered_accounts, all_quotas, threshold): mail_cfg = config["mail"] # Create subject based on number of accounts @@ -199,7 +199,7 @@ def send_warning(config, triggered_accounts, all_quotas): body_lines.append(f"The mailbox for account '{account_name}' has reached {quota_info['percent_used']:.1f}% of its quota.") body_lines.append(f"Usage: {format_bytes(quota_info['used_kb'])} of {format_bytes(quota_info['limit_kb'])}") else: - body_lines.append("The following mailboxes have exceeded the quota threshold:") + body_lines.append(f"The following mailboxes have exceeded the quota threshold ({threshold}%):") body_lines.append("") for account_name, quota_info in triggered_accounts.items(): body_lines.append(f"• {account_name}: {quota_info['percent_used']:.1f}% ({format_bytes(quota_info['used_kb'])} of {format_bytes(quota_info['limit_kb'])})") @@ -287,7 +287,7 @@ def main(): # Send consolidated warning email if any accounts triggered if triggered_accounts: - send_warning(config, triggered_accounts, all_quotas) + send_warning(config, triggered_accounts, all_quotas, threshold) save_state(state)