chore(api/libs): Apply ruff format. (#7301)
This commit is contained in:
@@ -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
|
||||
|
Reference in New Issue
Block a user