Exception handling and logging for SMTP errors
Should mitigate internal server errors if SMTP server fails.
This commit is contained in:
@@ -6,6 +6,7 @@ from .test import Test
|
||||
|
||||
from flask_login import current_user
|
||||
from flask_mail import Message
|
||||
from smtplib import SMTPException
|
||||
|
||||
from datetime import datetime, timedelta
|
||||
from uuid import uuid4
|
||||
@@ -174,4 +175,7 @@ class Entry(db.Model):
|
||||
<p>Best wishes, <br/> SKA Refereeing</p>
|
||||
"""
|
||||
)
|
||||
mail.send(email)
|
||||
try:
|
||||
mail.send(email)
|
||||
except SMTPException as exception:
|
||||
write('system.log', f'SMTP Error when trying to notify results to {self.get_surname()}, {self.get_first_name()} with error: {exception}')
|
Reference in New Issue
Block a user