File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import asyncio
22import smtplib
3+ import traceback
34from contextlib import asynccontextmanager
4- from datetime import date , datetime , time as dt_time , timedelta
5+ from datetime import date , datetime
6+ from datetime import time as dt_time
7+ from datetime import timedelta
58from email .message import EmailMessage
69from email .mime .text import MIMEText
710from functools import wraps
@@ -265,10 +268,14 @@ async def handle_daily_emails(app):
265268 messages .append (msg )
266269
267270 with smtplib .SMTP_SSL ('smtp.gmail.com' , 465 ) as smtp :
268- smtp .login (app .config .NOREPLY_EMAIL , app .config .EMAIL_APP_PASSWORD )
269-
270- for msg in messages :
271- smtp .send_message (msg )
271+ try :
272+ smtp .login (app .config .NOREPLY_EMAIL , app .config .EMAIL_APP_PASSWORD )
273+ except smtplib .SMTPAuthenticationError :
274+ # Prevent failure of email scheduling if Google's servers crash (like on 12/14/20)
275+ print (traceback .format_exc ())
276+ else :
277+ for msg in messages :
278+ smtp .send_message (msg )
272279
273280 # Prevent it from sending twice
274281 await asyncio .sleep (1 )
You can’t perform that action at this time.
0 commit comments