2024-05-04 10:18:01 +02:00
|
|
|
from flask_mail import Message
|
|
|
|
|
|
|
|
from app import flask_mail
|
|
|
|
|
2024-06-02 22:41:14 +02:00
|
|
|
from app.mail.message_content import MessageContent
|
2024-05-04 10:18:01 +02:00
|
|
|
|
|
|
|
|
2024-06-02 22:41:14 +02:00
|
|
|
def send_mail(message: MessageContent, recipient: str):
|
2024-05-04 10:18:01 +02:00
|
|
|
|
2024-06-02 22:41:14 +02:00
|
|
|
msg = Message(subject=message.subject, recipients=[recipient], body=message.body)
|
2024-05-04 10:18:01 +02:00
|
|
|
|
2024-06-02 22:41:14 +02:00
|
|
|
try:
|
|
|
|
flask_mail.send(msg)
|
|
|
|
return True
|
|
|
|
except Exception as e:
|
|
|
|
print(f"Failed to send email. Error: {e}")
|
|
|
|
return False
|