Example #1
0
A module for sending email.

This module defines a Celery task for sending emails in a worker process.
"""
from __future__ import unicode_literals

import smtplib

import pyramid_mailer
import pyramid_mailer.message

from h.celery import celery, get_task_logger

__all__ = ('send',)

log = get_task_logger(__name__)


@celery.task(bind=True, max_retries=3)
def send(self, recipients, subject, body, html=None):
    """
    Send an email.

    :param recipients: the list of email addresses to send the email to
    :type recipients: list of unicode strings

    :param subject: the subject of the email
    :type subject: unicode

    :param body: the body of the email
    :type body: unicode
Example #2
0
# pylint: disable=no-member # Instance of 'Celery' has no 'request' member
"""
A module for sending email.

This module defines a Celery task for sending emails in a worker process.
"""
import smtplib

import pyramid_mailer
import pyramid_mailer.message

from h.celery import celery, get_task_logger

__all__ = ("send", )

log = get_task_logger(__name__)


@celery.task(bind=True, max_retries=3)
def send(self, recipients, subject, body, html=None):
    """
    Send an email.

    :param recipients: the list of email addresses to send the email to
    :type recipients: list of unicode strings

    :param subject: the subject of the email
    :type subject: unicode

    :param body: the body of the email
    :type body: unicode