Files
goodtimes/manage_communications/utils.py
2024-04-10 12:57:44 +05:30

16 lines
667 B
Python

import logging
from threading import Thread
# Configure logging at the beginning of your application
logging.basicConfig(level=logging.INFO, filename='app.log', filemode='a', format='%(name)s - %(levelname)s - %(message)s')
def send_email_async(email_service):
try:
email_service.send()
print("Email sent from utils successfully!")
except Exception as e:
# Log the exception
print(f"Failed to send email: {e}")
logging.error(f"Failed to send email: {e}")
# Optionally, you could use other means to notify you of the failure,
# such as sending an alert to an admin email, or using a monitoring service.