2017-10-01 19:54:34 +00:00
|
|
|
import logging
|
2019-03-11 08:21:29 +00:00
|
|
|
import dramatiq
|
2017-10-01 19:54:34 +00:00
|
|
|
|
|
|
|
from options.options import SysOptions
|
2019-03-11 08:21:29 +00:00
|
|
|
from utils.shortcuts import send_email, DRAMATIQ_WORKER_ARGS
|
2017-10-01 19:54:34 +00:00
|
|
|
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
2017-04-18 17:37:10 +00:00
|
|
|
|
2019-03-11 08:21:29 +00:00
|
|
|
@dramatiq.actor(**DRAMATIQ_WORKER_ARGS(max_retries=3))
|
2017-12-24 03:34:40 +00:00
|
|
|
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)
|