From 782f3202e3833587ffb842dbf0bdb36bc6878d88 Mon Sep 17 00:00:00 2001 From: Luca Beltrame Date: Sat, 28 Aug 2021 22:43:21 +0200 Subject: [PATCH] Update to not send mails in case nothing changes Future TODO: Send update if expiry is close (< 30 days) --- sysadmin/letsencrypt_mail.py | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/sysadmin/letsencrypt_mail.py b/sysadmin/letsencrypt_mail.py index 1135826..749da29 100755 --- a/sysadmin/letsencrypt_mail.py +++ b/sysadmin/letsencrypt_mail.py @@ -44,17 +44,16 @@ def main(): elif "unexpected error occurred" in line: state = State.error - text = "\n".join(text) - subject = SUBJECT.format(str(state)) - message = drymail.Message( - sender=("Certbot renewal bot", "notify@dennogumi.org"), - receivers=["root"], - subject=subject, - headers=HEADER, - text=text - ) - - + if state is not State.no_action: + text = "\n".join(text) + subject = SUBJECT.format(str(state)) + message = drymail.Message( + sender=("Certbot renewal bot", "notify@dennogumi.org"), + receivers=["root"], + subject=subject, + headers=HEADER, + text=text + ) client = drymail.SMTPMailer( host='localhost')