From b887256b011824b57fd3a985282f0d869ab91dc7 Mon Sep 17 00:00:00 2001 From: Christine Cunningham <5705329+ccunningham101@users.noreply.github.com> Date: Fri, 12 Jan 2024 13:34:57 +0000 Subject: [PATCH] Skip encoding errors These emails will fail to send --- .../commands/send_retraction_emails.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/retractions/management/commands/send_retraction_emails.py b/retractions/management/commands/send_retraction_emails.py index ef38cb4..29aa9ea 100644 --- a/retractions/management/commands/send_retraction_emails.py +++ b/retractions/management/commands/send_retraction_emails.py @@ -159,12 +159,18 @@ def _get_mail_to_send(self, author, intervention_pairs): (author_alias.full_name(), self.test_email) ) else: - to_email = email.utils.formataddr( - ( - author_alias.full_name(), - author_alias.email_address, + try: + to_email = email.utils.formataddr( + ( + author_alias.full_name(), + author_alias.email_address, + ) ) - ) + except UnicodeEncodeError: + logging.warning( + "Skipping %s, invalid ascii", author_alias.email_address + ) + continue to_emails.append(to_email) # If no emails to send to, skip this author