This document describes the current stable version of Celery (3.1). For development docs, go here.

celery.utils.mail

celery.utils.mail

How task error emails are formatted and sent.

exception celery.utils.mail.SendmailWarning[source]

Problem happened while sending the email message.

class celery.utils.mail.Message(to=None, sender=None, subject=None, body=None, charset='us-ascii')[source]
class celery.utils.mail.Mailer(host='localhost', port=0, user=None, password=None, timeout=2, use_ssl=False, use_tls=False)[source]
send(message, fail_silently=False, **kwargs)[source]
class celery.utils.mail.ErrorMail(task, **kwargs)[source]

Defines how and when task error e-mails should be sent.

Parameters:task – The task instance that raised the error.

subject and body are format strings which are passed a context containing the following keys:

  • name

    Name of the task.

  • id

    UUID of the task.

  • exc

    String representation of the exception.

  • args

    Positional arguments.

  • kwargs

    Keyword arguments.

  • traceback

    String representation of the traceback.

  • hostname

    Worker nodename.

EMAIL_SIGNATURE_SEP = '-- '
body = '\nTask {name} with id {id} raised exception:\n{exc!r}\n\n\nTask was called with args: {args} kwargs: {kwargs}.\n\nThe contents of the full traceback was:\n\n{traceback}\n\n-- \nJust to let you know,\npy-celery at {hostname}.\n'

Format string used to generate error email content.

format_body(context)[source]
format_subject(context)[source]
send(context, exc, fail_silently=True)[source]
should_send(context, exc)[source]

Return true or false depending on if a task error mail should be sent for this type of error.

subject = ' [{hostname}] Error: Task {name} ({id}): {exc!r}\n '

Format string used to generate error email subjects.