mail_update_draft
Edit an existing email draft by saving a new version and moving the old one to Trash; only specified fields change, and nothing is sent.
Instructions
Change a draft saved in Drafts by saving a new version and moving the old one to Trash; only the fields you pass change, and nothing is sent.
Use when: the owner wants edits to a draft before it goes out. Not for sending it (use mail_send_draft with the new uid), starting a new draft (use mail_send_message with draft=true), or changing mail already sent (not possible). Parameters:
uid and uidvalidity come from mail_search_messages(folder='Drafts'). Omit folder for Drafts; elsewhere the message must carry the \Draft flag.
Omitted to, cc, bcc and subject keep their values.
Omit both body and body_html to keep the text. body alone replaces it and drops any old HTML part; body_html alone leaves the plain-text part empty, so pass both for a formatted draft. The signature is appended when either is given.
attachments replaces every file; [] removes them all; omit it to keep them. Behavior:
The new version is saved before the old one goes to Trash, so a failure never loses the draft.
The old uid is dead afterwards: use the returned uid.
Reply threading headers are kept.
No recipient checks and no approval apply.
Each call makes another version. Returns: {status: draft_updated, folder, old_uid, old_draft, message_id, subject, to, cc, uid, uidvalidity}; when the server reports no new uid, a hint to find it with mail_search_messages replaces uid. Errors:
'No message with uid' or out-of-date uids: search Drafts again.
'is not a saved draft', an unusable address, or an oversized attachment.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cc | No | Cc addresses (visible to all recipients). | |
| to | No | New recipients; omit to keep. | |
| bcc | No | Bcc addresses (hidden from other recipients). | |
| uid | Yes | The draft's uid in Drafts. | |
| body | No | New plain-text body (the signature is added); omit to keep the current body. | |
| folder | No | Where the draft is; default Drafts. | Drafts |
| subject | No | New subject; omit to keep. | |
| body_html | No | Optional HTML version of the body; the plain-text 'body' is always required. | |
| attachments | No | Files to attach (from mail_get_attachment as is; from drive_get_file, name and data_base64 go in filename and content_base64). | |
| uidvalidity | Yes | The 'uidvalidity' from the result the uids came from (required: a renumbered folder is refused, not misread). |