imap_add_keyword
Apply a custom IMAP keyword (like a color label or tag) to an email, passing the keyword exactly as given while rejecting system flags like \\Seen or \\Flagged.
Instructions
Set an arbitrary custom (non-system) IMAP keyword/label on an email — e.g. a provider color label like Open-Xchange's $cl_1..$cl_10, Apple Mail's $MailFlagBit0..$MailFlagBit2, or an app tag such as $promotion. Unlike imap_flag_email (which only ever sets the system \Flagged flag), this passes the keyword through verbatim, but rejects backslash-prefixed system flags (e.g. \Flagged, \Seen, \Deleted) — use the dedicated flag/read tools for those. Not every IMAP server permits custom keywords (see the mailbox's PERMANENTFLAGS) — if the server rejects or silently ignores the change, this call fails rather than reporting success.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| uid | Yes | Email UID | |
| folder | No | Folder name | INBOX |
| keyword | Yes | IMAP keyword to set, passed through verbatim (e.g. "$cl_3", "$MailFlagBit0", "$Junk") | |
| accountId | No | Account ID (from imap_list_accounts). Optional if accountName is given or only one account is configured. | |
| accountName | No | Account name instead of accountId. Optional if accountId is given or only one account is configured. |