From d7ee1c23f3df74f03327b8abd3db8d3531839c05 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Wed, 21 Dec 2022 20:43:30 +0100 Subject: [PATCH] certificate: be more resilient when mail cant be sent to root for some reason .. --- src/certificate.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/certificate.py b/src/certificate.py index 0fca3bf07..577048777 100644 --- a/src/certificate.py +++ b/src/certificate.py @@ -455,11 +455,15 @@ investigate : -- Certificate Manager """ - import smtplib - - smtp = smtplib.SMTP("localhost") - smtp.sendmail(from_, [to_], message.encode("utf-8")) - smtp.quit() + try: + import smtplib + smtp = smtplib.SMTP("localhost") + smtp.sendmail(from_, [to_], message.encode("utf-8")) + smtp.quit() + except Exception as e: + # Dont miserably crash the whole auto renew cert when one renewal fails ... + # cf boring cases like https://github.com/YunoHost/issues/issues/2102 + logger.exception(f"Failed to send mail about cert renewal failure ... : {e}") def _check_acme_challenge_configuration(domain):