Skip to main 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

Fields

FieldTypeRequiredDescriptionValidators
tolist[str]Recipient email addressesminLen: 1
subjectstrEmail subject linemaxLen: 500
bodystrEmail body (HTML)-
ccNoneCarbon copy recipients-
bccNoneBlind carbon copy recipients-
text_bodyNonePlain text alternative-
statusstrQueue status (Queued, Sending, Sent, Failed)-
prioritystrEmail priority (low, normal, high)-
errorNoneError message if failed-
retry_countintNumber of retry attemptsmin: 0
max_retriesintMaximum retry attemptsmin: 0, max: 10
queued_atdatetimeWhen the email was queued (UTC)-
sent_atNoneWhen the email was sent (UTC)-
from_addressNoneSender email address (uses default if not specified)-
reply_toNoneReply-to address-
attachmentsNoneAttachment metadata (file_id, filename, content_type)-
reference_doctypeNoneRelated DocType (e.g., Invoice)-
reference_idNoneRelated document ID-

Permissions

RoleCreateDeleteReadWrite
System Manager

Configuration

SettingValue
SubmittableFalse
Track ChangesTrue

Controller

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