コード例 #1
0
ファイル: __init__.py プロジェクト: clvrobj/ninemit
def send_mail(subject, content, from_email, to, eta=None, task_id=None):
    if USE_CELERY:
        from postman.tasks import send_mail_task#, send_mail_task_test
        send_mail_task.apply_async(args=[subject, content, from_email, to], eta=eta, task_id=task_id)
    else:
        if not eta:
            from ninemitutil import send_html_mail
            send_html_mail(subject, content, from_email, to)
コード例 #2
0
ファイル: tasks.py プロジェクト: clvrobj/ninemit
def send_mail_task_test(subject, content, from_email, to, **kwargs):
    logger = send_mail_task.get_logger(**kwargs)
    try:
        send_html_mail(subject, content, from_email, to)
        logger.debug("Successfully sent email message to %r.", to)
    except Exception as e:
        import traceback
        logger.error(traceback.format_exc())
        logger.error("Failed to send email message to %r.", to)
コード例 #3
0
ファイル: tasks.py プロジェクト: clvrobj/ninemit
def send_mail_task(subject, content, from_email, to, **kwargs):
    logger = send_mail_task.get_logger(**kwargs)
    try:
        send_html_mail(subject, content, from_email, to)
        logger.debug("Successfully sent email message to %r.", to)
    except Exception as e:
        try:
            send_mail_task.retry(args=[subject, content, from_email, to], kwargs=kwargs)
            import traceback
            logger.debug("Failed to send email message to %r, retrying. Exception:%s",
                        (to,taceback.format_exc()))
        except send_mail_task.MaxRetriesExceededError:
            logger.error("Max retries exceeded trying to send email to %r.", to)