OnlineJudge/account/tasks.py

24 lines
604 B
Python
Raw Normal View History

2017-10-01 19:54:34 +00:00
import logging
from celery import shared_task
2017-10-01 19:54:34 +00:00
from options.options import SysOptions
2017-12-24 03:34:40 +00:00
from utils.shortcuts import send_email
2017-10-01 19:54:34 +00:00
logger = logging.getLogger(__name__)
2017-04-18 17:37:10 +00:00
2017-12-24 03:34:40 +00:00
@shared_task
def send_email_async(from_name, to_email, to_name, subject, content):
if not SysOptions.smtp_config:
2017-10-01 19:54:34 +00:00
return
try:
2017-12-24 03:34:40 +00:00
send_email(smtp_config=SysOptions.smtp_config,
from_name=from_name,
to_email=to_email,
to_name=to_name,
subject=subject,
content=content)
2017-10-01 19:54:34 +00:00
except Exception as e:
logger.exception(e)