From 79028820082a665edffe111c4d1c0b0d58239628 Mon Sep 17 00:00:00 2001 From: AlexCXC <1223408988@qq.com> Date: Thu, 12 Dec 2024 15:24:10 +0800 Subject: [PATCH] fix SMTPSendEmail attr-validate and fix ThirdPartyAccountNotFound ThirdPartyAccountInvalid extend Exception --- dtable_events/utils/email_sender.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/dtable_events/utils/email_sender.py b/dtable_events/utils/email_sender.py index 3e5dd06a..bd3d4008 100644 --- a/dtable_events/utils/email_sender.py +++ b/dtable_events/utils/email_sender.py @@ -17,10 +17,10 @@ dtable_message_logger = setup_logger('dtable_events_message.log') -class ThirdPartyAccountNotFound(BaseException): +class ThirdPartyAccountNotFound(Exception): pass -class ThirdPartyAccountInvalid(BaseException): +class ThirdPartyAccountInvalid(Exception): pass class _SendEmailBaseClass(ABC): @@ -128,7 +128,7 @@ def __init__(self, db_session, account_id, detail, operator): self.sender_email = detail.get('sender_email') self.operator = operator - if not all([self.email_host, self.email_port, self.host_user, self.password, self.sender_name, self.sender_email]): + if not all([self.email_host, self.email_port, self.host_user, self.password]): raise ThirdPartyAccountInvalid('Third party account %s is invalid.' % self.account_id) def send(self, send_info): @@ -499,6 +499,7 @@ def close(self): self.db_session.close() def toggle_send_email(account_id, send_info, username, config): + result = {} try: sender = EmailSender(account_id, username, config) result = sender.send(send_info)