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
| 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 | list[str] | None | Carbon copy recipients | |
| bcc | list[str] | None | Blind carbon copy recipients | |
| text_body | str | None | Plain text alternative | |
| status | str | Queue status (Queued, Sending, Sent, Failed) | - | |
| priority | str | Email priority (low, normal, high) | - | |
| error | str | 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 | datetime | None | When the email was sent (UTC) | |
| from_address | str | None | Sender email address (uses default if not specified) | |
| reply_to | str | None | Reply-to address | |
| attachments | list[dict[str, Any]] | None | Attachment metadata (file_id, filename, content_type) | |
| reference_doctype | str | None | Related DocType (e.g., Invoice) | |
| reference_id | str | None | Related document ID |
Permissions
| Role | Create | Delete | Read | Write |
|---|---|---|---|---|
| System Manager | ✓ | ✓ | ✓ | ✓ |
Configuration
| Setting | Value |
|---|---|
| Submittable | False |
| Track Changes | True |
Controller
Controller hooks are implemented in *_controller.py files.
Available lifecycle hooks:
validate()- Called before save, raise exceptions for validation errorsbefore_insert()- Called before inserting a new documentafter_insert()- Called after successfully insertingbefore_save()- Called before saving (insert or update)after_save()- Called after savingbefore_delete()- Called before deletingafter_delete()- Called after deleting