chore(api/libs): Apply ruff format. (#7301)

This commit is contained in:
-LAN-
2024-08-15 17:53:12 +08:00
committed by GitHub
parent d07b2b9915
commit 9414143b5f
15 changed files with 270 additions and 320 deletions

View File

@@ -5,7 +5,9 @@ from email.mime.text import MIMEText
class SMTPClient:
def __init__(self, server: str, port: int, username: str, password: str, _from: str, use_tls=False, opportunistic_tls=False):
def __init__(
self, server: str, port: int, username: str, password: str, _from: str, use_tls=False, opportunistic_tls=False
):
self.server = server
self.port = port
self._from = _from
@@ -25,17 +27,17 @@ class SMTPClient:
smtp = smtplib.SMTP_SSL(self.server, self.port, timeout=10)
else:
smtp = smtplib.SMTP(self.server, self.port, timeout=10)
if self.username and self.password:
smtp.login(self.username, self.password)
msg = MIMEMultipart()
msg['Subject'] = mail['subject']
msg['From'] = self._from
msg['To'] = mail['to']
msg.attach(MIMEText(mail['html'], 'html'))
msg["Subject"] = mail["subject"]
msg["From"] = self._from
msg["To"] = mail["to"]
msg.attach(MIMEText(mail["html"], "html"))
smtp.sendmail(self._from, mail['to'], msg.as_string())
smtp.sendmail(self._from, mail["to"], msg.as_string())
except smtplib.SMTPException as e:
logging.error(f"SMTP error occurred: {str(e)}")
raise