add forgot password page
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import logging
|
||||
from email.mime.multipart import MIMEMultipart
|
||||
from email.mime.text import MIMEText
|
||||
from smtplib import SMTP
|
||||
from email.message import EmailMessage
|
||||
import aiosmtplib
|
||||
|
||||
from src.ez_lan_manager.types.ConfigurationTypes import MailingServiceConfiguration
|
||||
|
||||
@@ -11,20 +10,20 @@ class MailingService:
|
||||
def __init__(self, configuration: MailingServiceConfiguration):
|
||||
self._config = configuration
|
||||
|
||||
def send_email(self, subject: str, body: str, receiver: str) -> None:
|
||||
# ToDo: Check with Rio/FastAPI if this needs to be ASYNC
|
||||
async def send_email(self, subject: str, body: str, receiver: str) -> None:
|
||||
try:
|
||||
msg = MIMEMultipart()
|
||||
msg['From'] = self._config.sender
|
||||
msg['To'] = receiver
|
||||
msg['Subject'] = subject
|
||||
|
||||
msg.attach(MIMEText(body, 'plain'))
|
||||
|
||||
with SMTP(self._config.smtp_server, self._config.smtp_port) as server:
|
||||
server.starttls()
|
||||
server.login(self._config.username, self._config.password)
|
||||
server.sendmail(self._config.sender, receiver, msg.as_string())
|
||||
message = EmailMessage()
|
||||
message["From"] = self._config.sender
|
||||
message["To"] = receiver
|
||||
message["Subject"] = subject
|
||||
message.set_content(body)
|
||||
|
||||
await aiosmtplib.send(
|
||||
message,
|
||||
hostname=self._config.smtp_server,
|
||||
port=self._config.smtp_port,
|
||||
username=self._config.username,
|
||||
password=self._config.password
|
||||
)
|
||||
except Exception as e:
|
||||
logger.error(f"Failed to send email: {e}")
|
||||
|
||||
Reference in New Issue
Block a user