Skip to content

EmailQueue

Email queue DocType.

Stores outbound emails for asynchronous processing.
Attributes:
to: List of recipient email addresses
cc: Carbon copy recipients
bcc: Blind carbon copy recipients
subject: Email subject line
body: Email body (HTML)
text_body: Plain text alternative
status: Queue status (Queued, Sending, Sent, Failed)
priority: Email priority (low, normal, high)
error: Error message if failed
retry_count: Number of retry attempts
max_retries: Maximum retry attempts
queued_at: When the email was queued
sent_at: When the email was sent
from_address: Sender email address
reply_to: Reply-to address
attachments: Attachment metadata
reference_doctype: Related DocType (optional)
reference_id: Related document ID (optional)
Example:
email = EmailQueue(
to=["user@example.com"],
subject="Invoice",
body="<p>Your invoice is attached.</p>",
)

Source: email_queue.py

Field Type Required Description Validators
to list[str] Recipient email addresses minLen: 1
subject str Email subject line maxLen: 500
body str Email body (HTML) -
cc None Carbon copy recipients -
bcc None Blind carbon copy recipients -
text_body None Plain text alternative -
status str Queue status (Queued, Sending, Sent, Failed) -
priority str Email priority (low, normal, high) -
error None Error message if failed -
retry_count int Number of retry attempts min: 0
max_retries int Maximum retry attempts min: 0, max: 10
queued_at datetime When the email was queued (UTC) -
sent_at None When the email was sent (UTC) -
from_address None Sender email address (uses default if not specified) -
reply_to None Reply-to address -
attachments None Attachment metadata (file_id, filename, content_type) -
reference_doctype None Related DocType (e.g., Invoice) -
reference_id None Related document ID -
Role Create Delete Read Write
System Manager
Setting Value
Submittable False
Track Changes True

Controller hooks are implemented in *_controller.py files. Available lifecycle hooks:

  • validate() - Called before save, raise exceptions for validation errors
  • before_insert() - Called before inserting a new document
  • after_insert() - Called after successfully inserting
  • before_save() - Called before saving (insert or update)
  • after_save() - Called after saving
  • before_delete() - Called before deleting
  • after_delete() - Called after deleting