2017-10-02 03:54:34 +08:00
|
|
|
import logging
|
2019-03-11 16:21:29 +08:00
|
|
|
import dramatiq
|
2017-10-02 03:54:34 +08:00
|
|
|
|
|
|
|
from options.options import SysOptions
|
2019-03-11 16:21:29 +08:00
|
|
|
from utils.shortcuts import send_email, DRAMATIQ_WORKER_ARGS
|
2017-10-02 03:54:34 +08:00
|
|
|
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
2017-04-19 01:37:10 +08:00
|
|
|
|
2019-03-11 16:21:29 +08:00
|
|
|
@dramatiq.actor(**DRAMATIQ_WORKER_ARGS(max_retries=3))
|
2017-12-24 11:34:40 +08:00
|
|
|
def send_email_async(from_name, to_email, to_name, subject, content):
|
|
|
|
if not SysOptions.smtp_config:
|
2017-10-02 03:54:34 +08:00
|
|
|
return
|
|
|
|
try:
|
2017-12-24 11:34:40 +08: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-02 03:54:34 +08:00
|
|
|
except Exception as e:
|
|
|
|
logger.exception(e)
|