This commit is contained in:
Scott Idem
2022-12-01 18:03:54 -05:00
parent 1b18bdbfb6
commit 6e51cd0305
2 changed files with 5 additions and 1 deletions

View File

@@ -403,8 +403,11 @@ def send_email(
log.info('SMTP configuration, connect, and send')
try:
with smtplib.SMTP_SSL(settings.SMTP['server_name'], settings.SMTP['server_port'], context=context) as server:
with smtplib.SMTP_SSL(settings.SMTP['server'], settings.SMTP['port'], context=context) as server:
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug('SMTP log in...')
server.login(settings.SMTP['username'], settings.SMTP['password'])
log.debug('SMTP send message...')
server.send_message(message)
log.info('Email sent')
return True

View File

@@ -704,6 +704,7 @@ def email_user_auth_key_url(
<p>Thank you!</p>
"""
log.info('Trying send_email()...')
if send_email(from_email=from_email, from_name=from_name, to_email=to_email, to_name=to_name, bcc_email=bcc_email, bcc_name=bcc_name, subject=subject, body_text=None, body_html=body_html):
log.info(f'An email with a one time use sign in link was sent to {to_email}.')
return True