Repository navigation
Fixed
send_draftfinds a draft bymessage_idon iCloud
(#752).
iCloud'sHEADER Message-IDsearch matches only the whole value with its
angle brackets (measured 2026-11-22); the tools searched without them, so a
draft made byappend_draftcould not be sent by itsmessage_id, the
check for an existing sent copy could never find one, andappend_draft's
search after anunknownoutcome could never confirm the draft. Every
Message-ID search now asks for both forms in oneORand compares each hit
in full, as before. Theserver_replyinsend_draftresults no longer
repeats the reply code (250 250 2.0.0 Ok).send_draftandappend_draftcan use a server that does not mark its
drafts and sent mailboxes, whendirect-transport.jsonnames them (#748).
The first run against iCloud stopped at "the server marks no mailbox
\Drafts": the plain mailbox list marked no\Drafts, and the server did not
advertiseSPECIAL-USEbefore login (what it advertises after login was not
observed). The tools now try,
in order: the plain list's mark; when the server advertisesSPECIAL-USE, a
LIST ... RETURN (SPECIAL-USE); the exact name given by the new optional
drafts_mailbox/sent_mailboxkeys indirect-transport.json, if the
server lists that mailbox. A mailbox is never chosen by guessing from its
name, and a configured name must match the server's scalar by scalar. When
the configured name cannot be used either, the refusal says how many
mailboxes were listed and whetherSPECIAL-USEis advertised; results note
how each mailbox was found. When the sent and drafts mailboxes are the same
mailbox (compared without regard to ASCII case), the sent copy stays
pending and the draft is kept. A pending removal is done only in the drafts
mailbox the draft was submitted from. When the drafts mailbox is looked up,
a marked mailbox that cannot be selected, capabilities that cannot be read,
or a failed special-use request refuse the call; when the sent mailbox is
looked up after submission, they leave the sent copy pending.
Added
-
send_draftrefuses a draft Mail saved
(#745). The
Mail draft compared for #745 had an empty plain-text part, the body in HTML
and draft-only headers such asX-Uniform-Type-Identifier: com.apple.mail-draft,
while a message Mail sent was a single plain-text part.send_draftsends
drafts as stored, so a new submission of a draft carrying that mark is now
refused before connecting to the SMTP server (only the mark is checked); make the draft withappend_draft, or send it from Mail. Pending
stages of a draft submitted earlier are still completed. -
append_draft: create a draft on the mail server over IMAP, without Mail
(#744, second
stage of #729).
Not yet run against a real mail server; the tool description says so until
the result is recorded on #744. Same accounts, credential and connection rules
assend_draft. The tool builds onetext/plainpart in UTF-8 with a new
Message-ID and appends it to the mailbox the server marks\Drafts, with
\Draftand\Seen. Recipients are bare addresses only. The outcome is
appended,not_appended(including a failed connection, login or
drafts-mailbox lookup before the APPEND was sent) orunknown; afterunknown
it tries one search for the Message-ID and never appends again. Calls are not
de-duplicated. The message is deliberately not in the
layout Mail gives its own drafts
(#745). -
send_draftacceptsmessage_idas a third way to choose the draft, beside
draft_idandsubject_match, so a draft made byappend_draftcan be sent
while Mail is closed (#744). -
send_draft: send an existing draft over SMTP, without Mail
(#742, first
stage of #729).
Not yet run against a real mail server; the tool description says so until
the result is recorded on #742. Only for accounts listed in
~/.claude/.mail/direct-transport.json, with a password stored in the
server's own keychain item by--direct-transport-set-credential <address>
(read from standard input; no tool can read or change it, and Mail's
passwords are never read). The draft is chosen bydraft_idor by exact
subject_matchin the server's\Draftsmailbox; the tool accepts no body,
recipient or attachment argument. Before submitting it checks the Message-ID
against a record of sent drafts, the From address, the recipients and the
header; it submits the draft without its Bcc fields, over TLS only (implicit
on 465/993, required STARTTLS elsewhere). The outcome issubmitted,
not_sentorunknown; an unknown send is not retried and is cleared only by
--direct-transport-forget '<message-id>'. After a submission the sent copy
and the draft's removal are separate stages that a later call resumes without
submitting again, only from the same account and only while the draft is
byte for byte the one submitted. One call runs at a time, and the SMTP server
is contacted only to submit. Errors and server replies are redacted of the
password. Mail's local index is not changed. New dependency: SwiftMail
1.17.0, pinned by revision. -
search_emailscan return each row's Message-ID
(#682). The new
include_message_id(boolean, default false) addsmessage_idto every
fullorsummaryrow, read from the.emlxheader block with the parser
get_emailand the batch export use. A non-empty string is the Message-ID and
equals whatget_emailreports (the header block ends at the first blank
line, see #715);
""means the message has no such header, or an empty one. A missing key means unknown, in
these cases only: no readable.emlxfor the row; the file could not be read
or its length line could not be parsed (including one longer than 4096
bytes); the header block does not end within the first 256 KiB of the message
(including a larger message whose lines end in lone CR); the value is longer
than 4096 UTF-8 bytes; or the row came from the AppleScript fallback. In the
middle threeget_emailmay still report a value, because it reads the whole
file. The read stops at the end of the header block, never looks at more than
the first 256 KiB of a message (the first 4096 bytes of the file are also read to find the
length line, whatever they hold) and looks up each mailbox's store folder
once per call; without the flag no file is read and rows are unchanged.true
withidsorcountand a non-boolean value are parameter errors. A call
whose rows could not all be read writes one stderr line with a count and a
fixed reason. Not yet run against a real mail store; the issue stays open for
that check. A plugin release that relies on the field must set
binary_versionto a binary that contains it. -
forward_emailcan save the forward as a draft
(#599). The new
save_as_draft(boolean, default false) saves a forward that carries a body
with ⌘S through the same paste path instead of sending it, like
reply_email's draft mode. A forward without a body and
save_as_draft: trueis refused by name before any Mail call, because the
bodyless forward is Mail's nativeforwardverb followed bysend; a
bodyless draft mode is tracked in
#673. Without
save_as_draftthe call sends, as before, and the tool description now says
so in its first sentence; it also advises reading a saved draft's To
recipients and body back before sending it.nullmeans the same as an
omittedsave_as_draft, as forreply_email; any other non-boolean value is
refused. A timeout on the draft path is not reported as an unknown send
state; the send path's handling is unchanged. The draft mode has not been run
against Mail yet. -
get_mail_log_eventscan filter by event name
(#466). The new
eventsparameter (1 to 20 values) keeps only events whoseeventfield is
exactly one of the values: a template,imap.append_uid_received, or
<template withheld>. It works in brief and detailed output, so the upload
receipt no longer has to be paged out of hundreds ofIMAPConnectionlines.
The comparison is against the name the output shows, by the same function, so
a withheld template cannot be selected by its own text, and nothing but exact
equality selects an event. Animap.value that is not a known event is an
error, so a typo does not read as "the event did not happen". Paging counts
only matching events. The values are not echoed: the response reports how
many were applied asevent_filter_count, so a large filter cannot push it
past the 64 KiB cap and caller text never comes back in brief output. -
The
.mcpbinstall can set the destination policy
(#574). The
bundle's manifest had no way to setCHE_MAIL_EXPORT_ALLOWED_ROOTS, so a
Claude Desktop user could not save attachments or export outside the home
folder (an external disk, for example). The extension now has an optional
Allowed save and export folders setting that maps onto the variable; it
takes the same colon-separated absolute paths and, when set, replaces the
home default. The README lists where to set the variable for each install
method. A value that is exactly the manifest's placeholder counts as unset, so
a host that passes an unset setting through literally keeps the home default.
How Claude Desktop passes an empty setting was not checked on a real install;
the setting has an empty default, and thesave_attachmentandoutput_dir
descriptions state the limit. Behaviour change: any other entry that is not
an absolute path now matches nothing, with a note on stderr. A relative entry
used to be resolved against the server's working directory; a nonempty value
with no absolute path in it now denies every destination.
Changed
-
BREAKING: requires macOS 26
(#742). The
minimum system goes from macOS 13 to macOS 26; macOS 13, 14 and 15 stay on
v4.x. The cause is a new dependency,SwiftMail(SMTP and IMAP, for sending
without Mail, #729), which needs macOS 15, and below macOS 26 the release
binary would also needlibswiftCompatibilitySpan.dylib, which macOS 15 does
not ship. The tools that use it aresend_draftandappend_draft.
Package.resolvedis now under version control, so a release binary can be
rebuilt from the same dependency versions (24 packages, up from 7). -
get_mail_log_eventssignals thelogchild's whole process group
(#646).
The runner now starts/usr/bin/logwithposix_spawnin a process group of
its own (POSIX_SPAWN_SETPGROUP), with only stdin (/dev/null), stdout and
stderr inherited (POSIX_SPAWN_CLOEXEC_DEFAULT) and default signal handling,
and reaps it itself. Every stop sends SIGTERM to the group, gives the leader
two seconds, sends SIGKILL to the group, and only then reaps the leader, so
the group number cannot belong to anyone else while it is signalled. A
descendant that held the child's stderr (or stdout) can no longer keep the
stderr reader thread and its descriptor alive: on a natural end the leader is
observed without being reaped, and if stderr has not closed within the
existing 2 s the group gets SIGKILL before the reap. The group is also swept
on a normal exit, so a descendant that holds neither pipe does not outlive the
call. The two-slot cap, the cancellation behaviour and the exit-status
semantics (-1for a child that could not be reaped) are unchanged. A spawn
failure still reportsspawnFailedwith the executable path and the reason
posix_spawngave. Remaining limit: a descendant that callssetsidorsetpgid
leaves the group and is not reached, and no test covers that case. No such
descendant is known forlog show --style ndjson; the tests use descendants
that stay in the group. -
Attachment paths must be regular files
(#543).
compose_emailandcreate_draftvalidated attachments only by existence,
symlink resolution, the deny-list and the optional allow-list, so a
directory, a FIFO or a device such as/dev/zeropassed. A path that is not a
regular file after symlink resolution is now rejected as
not a regular file (<kind>), in the same aggregated error and before Mail is
touched; the type is read without opening the path.update_draftgets the
same checks, now before its draft scans. A path with a.or..component
is refused ascontains a '.' or '..' path component: Mail receives the
caller's text through the open panel's Go-to-folder field, and without such
components every reading of the path names the same file. Components are compared as the filesystem sees them (the bytes between slashes), and a path that holds a NUL byte is refused by name. Resolution no
longer applies.standardizedfirst (it removed..from the text before
following links, so the deny-list, the allow-list and the type check could
judge a different file from the one named). A relative path still counts from
the server's working directory. Behaviour change: directories are rejected
too, including package documents such as.rtfdor.appbundles that Mail
might have attached before, and so are paths with.or..components. -
Direct-write trigger: the timed path is pinned as text
(#650). Tests and
docs only; nothing underSources/changed.ComposeTiming.preludeand
ComposeTiming.markStatementwere not compared with fixed text on the timed
path, so a toggle, a branch or adelayplaced in the mark handler would have
run between the two read-status toggles whenever timing is on and passed every
test. Three new tests pin the prelude,markStatementfor every label the
trigger uses, and the whole timed script (four marks, their places and
indentation). They pin the text the builder hands to the script transport (for one row id), not the bytes osascript receives and not Mail's reaction to it;
the rule's known-gap bullet is replaced by the test names and a note that
Mail's behaviour for the pinned script, the transport below the test seam and
the other non-text channels are a documented limit, not a pending live check.
The prelude is shared with the compose path's timing, so changing that now
means updating the pin. -
A handler test with an address as
account_nameno longer reads the machine's
accounts (#633).
A server built withaccountMappingnow resolves an address from that mapping.
Without one, nothing changes: the server still reads AccountsMap.plist on each call.
This coversaccount_name; the direct-write path'sfrom_addresslookup is
covered by #654 below. -
create_draft's direct-write path answers its account gate from an injected
mapping (#654).
A server built withaccountMappingnow gives the opt-in direct-write path that
mapping forfrom_address, and treats the account's signature list as
unreadable (the mapping holds none), sosignature: mail_defaulttakes the GUI
path there. Without a mapping, nothing changes: on each call the account lookup
reads AccountsMap.plist, and the signature lookup reads it too unless
iCloud-synced signatures exist (then the list counts as unreadable, as before). -
list_vip_senderscan read an injected VIP list
(#656).
EnvelopeIndexReaderand the server'sinittake an optional VIP list path,
so a handler test reads only the file it wrote, as long as the reader opens.
Without one, the reader reads the sameVIPMailboxes.plistas before; the path
is now built from the mail storage path, so it follows a test's override of
that path (production never sets one). When the reader is not open, the
handler still falls back to AppleScript, as before. -
BREAKING:
reply_emailrefusesattachmentsfor now
(#534).
With a non-emptyattachments, the reply script pasted the new body through
Mail's editor and then attached the file through Mail's scripting object
model. That insertion writes the reply'scontent, which holds neither the
pasted body nor the quote Mail'sreplyverb built, so the saved draft kept
only the attachment and the signature while the call returned
Reply saved as draft (paste path)(send mode used the same script). Any
non-emptyattachmentsis now refused before any Mail action, attachment-file
check or AppleScript, in draft and send mode alike, withinvalidParameter
naming the reason and the recipe: reply withsave_as_draft: trueand without
attachments, then open the saved reply from Drafts in Mail and drag the
files in. This is a temporary ninth refusal reason that applies to
reply_emailonly; it goes when
#608 attaches
through Mail's editor. The parameter stays in the schema so such a call is
refused by name. Argument parsing at the tool boundary still runs first, so
format: "markdown"or"html"with attachments reports the format refusal.
Reply and forward scripts without attachments are unchanged. -
reply_emailreports its refusal before an invalidcc_additional
(#534). The
cc_additionalcheck now runs after the pre-flight refusal, so a refused
reply reports the attachments refusal or the missing Accessibility grant
first, where an invalidcc_additionalused to be reported first; it is now
reported once the call would otherwise proceed. The format refusal was already
first, because the tool parsesformatbefore calling into Mail. Both orders
have no side effects. -
The object-model attachment code is removed, not bypassed
(#534).
attachmentFragment, its paced delays and the reply/forward attach drain are
gone, andNoObjectModelAttachmentGuardTestsfails if any source file under
Sources/CheAppleMailMCP/inserts an attachment through Mail's object model
again.CHE_MAIL_ATTACHMENT_DELAY_BETWEENand
CHE_MAIL_ATTACHMENT_DELAY_TRAILINGare no longer read: they only paced that
code, and compose attachments have gone through ⇧⌘A with the
CHE_MAIL_MAILTO_*delays since #304. -
The four tools that can send mail declare it in their MCP annotations
(#601).
compose_email,reply_email,forward_emailandredirect_emailnow carry
readOnlyHint: false,destructiveHint: true(a sent message cannot be
recalled),idempotentHint: false(a retry sends a second message, #242) and
openWorldHint: true(mail leaves for third parties). These are the values a
client conforming to the MCP spec already assumes for a tool without
annotations, so such a client behaves the same; the change makes them explicit
and keeps them if a client or SDK default changes. Annotations are static, so
reply_emaildeclares the send case even when it is called with
save_as_draft: true, so a client that asks before destructive tools will ask
before a draft-only reply too. Whether any client prompts on these hints was
not verified. -
Every tool now says what it does in its MCP annotations
(#621). Without
them a client read every tool as possibly destructive, so it could not tell a
read from a delete. Each tool now sits in one class of a closed table
(ToolAccess), and a test fails on a new tool with no class. Reads of accounts
and settings are read-only and closed world. Reads of mail are read-only and
open world, because third parties wrote that text.create_draftand
open_mailtosend nothing but are open world, because a draft syncs to the
server andopen_mailtohands over to the default mail client. Tools that
change, move, remove or import are destructive, as aresave_attachmentand
the exports (an attachment of the same name is replaced).update_draftis
destructive and open world. The classification tools andcheck_compose_length
keep the annotations they already had.A client that runs
readOnlyHinttools without asking will now read mail
without a prompt, and text in a message can then steer what gets read next.
The hint states a fact about the tool: it changes no mailbox, though a read can
make Mail fetch a body from the server (#274). Acting on it is the client's
policy. The MCP specification tells clients to treat annotations as untrusted
unless the server is trusted, andopenWorldHintdoes not make a client ask.
Whether any client acts on these hints was not verified. -
get_mail_log_eventsruns at most two reads at once and stops when the
client cancels (#467).
Each call started its ownlog showchild (237–350 MB) with no limit, and a
cancelled call left the child running until its 30-second deadline. A third
concurrent call now returns at once withstatus: unavailable,
reason: busyand starts nothing; a caller retries. A cancel stops reading
within one poll slice (250 ms), then terminates and reaps the child (at most
about 4 seconds for a child that ignores SIGTERM), and returns
reason: cancelled. The slot stays taken until then. A descendant
that holds the stderr pipe can still outlive the call, as before; putting the
child in its own process group is not part of this change. -
Removed attachment code that #402 left unused
(#575).
MailController.verifySavedAttachmentOnDisk,AttachmentWriteProblem.statFailed
andEmlxParser.saveAttachment(..., destination:)had no production caller; the
last wrote to a plain URL with no containment, so any future caller would have
reopened #402. The #314 and #347 tests now run againstsaveUsingScript, the
step that does this work, and a new structural test pins that a Tier-1
publication failure ends the call instead of reaching AppleScript. The tool's
behaviour does not change.
Fixed
-
forward_emailno longer sends a bare forward whenbodyhas the wrong type
(#674).body
is optional, and a value that was present but not a string (a number, a
boolean, an array, an object) was read as no body: withoutsave_as_draftthe
forward was sent without the note, and with it the call was refused for the
wrong reason. Such a call is now refused before any Mail action with
'body' must be a string, got: <type>, checked before the account is resolved.
An explicitbody: nullis refused the same way (got: null): callers that
passed null to mean "no note" must now leave the key out. A missingbodyis
still a forward without a body, and a string (the empty string included)
behaves as before. One case reads oddly: a
string that parses as adata:URL is decoded as binary data by the MCP SDK
before it reaches the tool, so it is refused asgot: data, and the message
says so. -
Header and fallback body decoding do linear work
(#720). Two
decoders did work that grew with the square of the value's length: the RFC 2047
encoded-word decode thatparseHeaderBlockapplies to every header value
exceptcontent-*, and the quoted-printable decode of the HTML body on the
AppleScript fallback path. Both now do work linear in the length of the value.
This is a performance fix only: the decoded output is unchanged (a differential
test compares both decoders with the previous algorithm, kept as a test-only
reference), and which text counts as an encoded-word, the charset run handling
(#352) and thecontent-*exemption (#115) are untouched. The tests count the
work through a seam instead of timing it. -
A message's header block ends at its first blank line
(#715).
RFC822Parser.parseHeadersandheaderBodySplitOffsetlooked for a CRLF blank
line over the whole message first and used an LF blank line only when no CRLF
blank line existed anywhere. A message whose header block ended with an LF blank
line and that had a CRLF blank line later was split at the later one, so body
lines were read as headers (the lastSubject:-style line won) and the body
started in the wrong place; this reachedget_email,get_emails_batch,get_email_headers, the
Markdown export, attachment lookup, the MIME child parts and the classification
tools. Both functions now
use one scan that ends the header block at the blank line that starts first.
Messages with consistent line endings, messages with no blank line and the
slice behaviour from #72 are unchanged. A blank line written\r\n\nends the
header block at its\n\n;\n\r\nis still not read as a blank line. Whether
mixed line endings occur in real mail stores has not been measured.
The Message-ID recipe in the repair command, which mirrors the parser, ends the
header block the same way, and the shared spelling fixture follows. -
The attachment deny-list no longer depends on how a path is spelled
(#671). The
deny-list compared the resolved path with each sensitive directory as text, so
a spelling that resolution keeps and the kernel still accepts (a root-level
prefix such as/.nofollowor/.resolve/<n>) named a deny-listed file
without matching. The check now also compares the device and inode of each
prefix of the resolved path with those of each deny-listed directory, so any
spelling of a deny-listed directory is refused, including spellings that
differ only in letter case. A prefix or a deny-listed directory that cannot be
examined rejects the path; a deny-listed directory that does not exist is
skipped. When a deny-listed directory exists but cannot be examined, every
attachment is refused with a message that says the deny-list check could not
be completed and names the directory and the system's reason. Hard links to a
deny-listed file are still not recognised (see
SECURITY.md). Tests use a temporary directory as the deny-listed root through
an internal parameter of the validator. -
A failed read of a direct draft's read flag says why
(#653). After the
upload, the direct-write path looks at the draft's local read flag; a read that
failed and a draft row that was gone both came back as "cannot tell", and the
cause of the failure was dropped. A failed read now writes
DraftStoreWriter: messages.read read failed (<cause>)to stderr, up to 12
lines for one draft (4 looks, then 8 after the re-assert); a row that is gone
still writes nothing. The result is unchanged: either case still counts as not
able to read the flag. -
A failed direct write no longer leaves empty directories behind
(#503). When the
opt-in direct write failed after placing the.emlx(or while placing it), or
was reversed after the upload request failed, it removed the file (and its
rows, except those #628 tracks) but left theMessagesdirectory, and any hash
directories above it, that it had created. That happens whenever the draft is
the first row of the Drafts mailbox in its 1,000-row block: row ids are shared
by all mailboxes while each mailbox has its own hash directories, so for a
Drafts mailbox with few messages it is the common case. It now removes the
directories it created, deepest first, and only while they are empty. Only a
level its ownmkdirmade is recorded, so a level that existed, or that
another process created first, is not removed; a directory Mail wrote into
meanwhile stays, with everything above it. A recorded directory that is
already gone is skipped. A removal that fails for any other reason than the
directory not being empty or already gone is noted on stderr and stops the
cleanup. Cleanup never replaces the error a failed write reports and never
makes a reversal fail. One error text did change: when a directory cannot be
created, theemlxWritereason now names the level and the system error
(could not create <path>: <reason>), so the fallback note carries that path,
as it already did for an existing.emlx. A narrow race remains: if Mail has
found a directory this write created and has not yet written into it, the
cleanup can remove it first. Two related gaps are tracked in
#666. -
A signed or fullwidth digit pair is no longer decoded as a hex escape
(#641). The
quoted-printable decoders and the percent decoder read the two characters after
=or%withUInt8(_, radix: 16), which accepts a leading sign, so=+5
decoded to the control byte 0x05,=-0to NUL and%+5to 0x05. All three
decoders (RFC822Parserfor bodies and RFC 2047Qwords,MIMEParserfor RFC
5987 / RFC 2231 file names, and the AppleScript fallback inMailController) now
read one sharedHexEscape.byte(_:_:), which takes ASCII0-9A-Fa-fonly, so a
sign, a space or a fullwidth digit leaves the=as text and%+5returns nil
like any other malformed percent escape; lowercase escapes decode as before. The
AppleScript fallback also stops dropping the two characters after a malformed
=:=ZZkeepsZZ. A guard test fails on aradix: 16parse inSources. -
A draft is not reported as uploaded when its queued action could not be read
(#630). While
waiting for the upload, the direct-write path treats a remote id with no queued
action as uploaded, and a failed read of the queued action counted as "none".
A failed read now counts as still queued, so the wait keeps looking and ends as
pending unless a later read confirms the upload. Both reads now say why they
failed on stderr, up to two lines per poll, about 200 lines per draft if they
keep failing. A read that keeps failing costs more than it did: the draft takes
the full wait instead of ending at once, longer if a held lock makes each read
wait out the 5-second busy timeout. A draft Mail did upload is then reported as
pending, and the read repair, which runs only after a confirmed upload, does not
run, so its local copy can stay unread. The 10-second limit itself is unchanged. -
A refused export path no longer says where it resolved
(#625). When
batch_export_emails_markdownrefusedoutput_diror
skip_message_ids_path, the error printed the validator's reason, which held
the symlink-resolved path and named the kind of refusal. Resolution runs before
the check, so a caller with only MCP tools could learn where a link points or
whether a protected folder exists. Both parameters now get one fixed message
whatever the kind, and the reason goes to stderr, assave_attachmenthas done
since #576. The<parameter> rejected by write-safety check:lead is unchanged;
only the text after it differs. -
Accounts added or renamed while the server runs resolve without a restart
(#554). The
SQLite reader built its account mapping from AccountsMap.plist once, when it
opened, so a name-scoped read (list_mailboxes,list_emails,
search_emailswithaccount_name) for an account added later failed with
accountNotResolvable, results named that account by its UUID, and a renamed
account resolved only under its old name. A lookup that misses now re-reads
the plist once and retries, at most once every 5 seconds, so a name that never
resolves costs one plist read per interval rather than one per call. A read
that returns no accounts (an unreadable plist) keeps the accounts already
known. The mapping is now guarded by a lock, because the reader is shared by
concurrent request handlers; the plist itself is read outside the lock.
Lookups byaccount_idwere not affected. A lookup that finds what it asked
for also checks, at most once every 5 seconds, whether the plist's modification
date changed, and re-reads it if so
(#615), so an
account whose email changed gets its new name in results and its old name stops
resolving, without a miss. The names are the account emails taken from
AccountsMap.plist, so renaming an account's description in Mail does not
change them. -
A failed read in the direct-write draft path no longer reads as an empty
answer (#618).
The check that refuses to roll back a draft Mail has already uploaded treated
a failed read as "not uploaded", so unless a later statement failed too, the
rollback went on to delete a draft that could be on the server. It now
refuses, and the result reports the draft as created with its upload not
confirmed. A mailbox scan that stops part-way answers nothing instead of
passing the single-mailbox gate on the rows it saw, with the SQLite error on
stderr, and a read that fails insideinsertreports that error instead of
"row missing". Experimental path only (CHE_MAIL_EXPERIMENTAL_DIRECT_DRAFT=1). -
A read that the Envelope Index stops part-way through is an error, not a
shorter answer (#549).
Every SQLite read stepped through its rows with
while sqlite3_step(stmt) == SQLITE_ROW, so any result other than a row
(SQLITE_BUSYafter the busy timeout,SQLITE_IOERR,SQLITE_CORRUPT)
read as "no more rows": a truncated mailbox list, search page or recipient
list came back as if complete, and an unread count or search count as0,
with nothing on stderr. Every multi-row read in the reader now checks that
SQLite reported the end of the results, and the one-row reads (unread count,
search count, message lookup, metadata, draft status) tell "no row" from a
failure; a failure throwsqueryFailednaming SQLite's message and result
code. A recipient read that fails now fails its search page, where it used to
leave the recipients empty.
list_mailboxes,get_unread_count,list_attachmentsandsearch_emails
(projection: "full") used to pass index errors to the caller; on a failed
read they now log it to stderr and use the AppleScript path, like the other
read tools. The SQLite-onlysearch_emailsprojections (ids,count,
summary) report the failure. Account and mailbox resolution errors are
answers, not failures, and still come back unchanged. The direct-write
create_draftpath names a failed mailbox read as the reason it was not
attempted, where it used to report "no Drafts mailbox path"; it still uses
the GUI path in that case. More AppleScript fallbacks may now run when the
index is busy or damaged, which is slower but no longer wrong. -
The Automation pre-flight no longer takes one empty running-application
list as "Mail is not running"
(#499). A test
harness sawNSRunningApplicationcome back empty for a running Mail under
load (1 to 4 runs in 33), which every GUI-path call would report as a false
"Mail is not running". An empty list is now re-read up to twice, 150 ms apart,
and only a list that stays empty reports not running, so a Mail that really is
closed gets that answer 300 ms later than before; nothing else about it changes.
A recovery goes to stderr, so the server's own rate can be seen; whether the
server sees this at all was not established. -
Saving an attachment works through a search-only folder, says less, cleans
up after a kill and drops inherited ACLs
(#576). Four
edge cases in the publisher #402 added:- The walk from
/opened each directory with read access, so an ancestor at
-wx--x--xfailed every save withdestination_write_failed, where the
path-based write before #402 needed only search permission. It now opens
withO_SEARCH, and falls back to read access on a filesystem that refuses
that.O_SEARCHwas not tested on network or FUSE mounts. The Markdown
export shares the walk and gets the same change. - A refused path now gets one fixed message that names no path. It used to
carry the resolved path, so a caller could learn where a symlink points or
whether a protected folder exists. The reason stays on stderr. A path that
fails to resolve outside the policy gets the same message; inside the policy
it keeps its specific reason. - A save now removes temporaries a killed server left in that folder: files
named by this writer, owned by this user, whose server is gone or which are
over a day old. Temporary names stay unique per save rather than fixed per
destination as the issue proposed, because concurrent saves must not touch
each other's file (#402); the name now carries the server's pid and a tag
for this Mac, so a shared or synced folder's file from another Mac goes by
age alone. A folder that cannot be listed is left alone. - A saved file no longer keeps an ACL inherited from its folder: a folder's
inheritable read entry made the 0600 temporary, and so the published file,
readable through it. A save fails if the ACL cannot be read on a volume that
may hold ACLs, or will not clear. Behaviour change: a file saved into a
folder that shares through an inherited ACL, or over a file with its own ACL,
ends up with no ACL.
- The walk from
Fixed
-
A quoted-printable soft break at the very end of a part no longer leaves a
stray=(#626).
The decoder's end-of-input guard ran before its soft-break test, so=plus a
line break that was the last thing in the input was written out verbatim.
Multipart text keeps the line break before the boundary (#546), which made this
visible at the end of a body. A lone=or a truncated escape such as=4
still stays literal. -
A header value no longer ends at a Unicode line character
(#555).
The header parser split lines withCharacterSet.newlines, which besides CR
and LF holds U+000B, U+000C, U+0085, U+2028 and U+2029. A value containing
one of them was cut there, and a tail shaped likeName: valuewas stored as
another header, so a sender could forgeMessage-ID,FromorDate(and a
MIME part'sContent-Type) from inside their ownSubject. Lines now end
only at CR or LF (a bare CR still ends a line, as before), and those
characters stay in the value. Archives exported earlier with a forged
message_idare not repaired. -
One non-UTF-8 part no longer blanks a multipart message's text and html
(#546).
The text/html walk behindget_email,get_emails_batchand both export
tools turned the whole multipart body into oneString, so a single byte that
is neither UTF-8 nor ASCII (a raw 8bit Big5 part, a lone0xE9) returned no
text and no html, the valid sibling part included. Parts are now split at the
byte level and decoded one by one under their own charset. The walk also stops
at the same nesting depth as the attachment walk (8), where it used to recurse
without a limit at quadratic cost. Well-formed UTF-8 mail returns the same
bodies as before, trailing line break included. -
A multipart preamble ending in a blank line no longer empties the text body
(#560).
The text before the first boundary (oftenThis is a multi-part message in MIME format.) was walked as a part. When a blank line followed it, it parsed
as an emptytext/plain, and the real plain part was then skipped, so
get_emailreturnedtext_body: ""and the exported Markdown body was empty
even though the message had a plain and an html part. The preamble is now
skipped, as the attachment walk already did. -
The opt-in direct write no longer writes lines over 998 octets
(#588).
WithCHE_MAIL_EXPERIMENTAL_DIRECT_DRAFT=1, an ASCII-only body went out as a
7bithtml part without folding, so a body line longer than 998 octets (the
RFC 5322 §2.1.1 limit) made the draft an invalid message that servers or
clients may rewrite or reject. Such a body now goes out as quoted-printable,
which soft-wraps at 76 characters, like non-ASCII bodies already did. Bodies
whose lines all fit keep the7bitlayout Mail itself writes, and the
create_draftdescription now states this behaviour. -
Decoding no longer depends on how Foundation treats
.ascii
(#561).
String(data:encoding: .ascii)succeeds on non-ASCII bytes in the shipped
binary (stamped sdk 13.0) and fails underswift test, so code that used it
did something different from what the tests saw. Every call site now says
what it means, and the results are the same under both stamps. What changes
for the shipped binary: a 7bit/8bit text part with non-ASCII bytes is no
longer taken for mislabelled quoted-printable; a quoted-printable part with
raw 8-bit bytes keeps those bytes instead of re-encoding each one as UTF-8
(caf\xC3\xA9=20xiscafé x, not mojibake); an encoded-word or RFC 2231
filename labelledus-asciithat carries valid UTF-8 now reads as UTF-8, the
rule bodies follow since #538. Non-UTF-8 bytes under an ASCII label still read
as Latin-1. -
Batch export dates now match the SOP recipe for old years and a bare
CST
(#547).
The frontmatterdateofTue, 30 Jun 55 10:00:00 +0800was
0055-06-30T10:00:00+08:00; two- and three-digit years now follow RFC 5322
§4.3 (55is 1955,49is 2049,126is 2026), as the recipe does. A bare
CST, which names both US Central and China Standard Time, was silently read
as US Central and could move the calendar day; a date ending inCSTor any
other zone name the recipe refuses now stays as written indate, and its
default filename usesunknown-date. Files already exported are not repaired. -
skip_message_ids_pathno longer splits a Message-ID at a Unicode line
character (#613).
The skip file was read withCharacterSet.newlines, so an ID holding U+2028
or a similar character (kept by the header parser since #555) became two
entries that matched nothing, and the mail was exported again. Lines now end
only at CR or LF. -
Frontmatter values can no longer start another line
(#616). YAML 1.1
readers and Python'sstr.splitlines()end a line at U+0085, U+2028 and U+2029,
which survived into the frontmatter, including the unquotedsenderand
date. These and the other C1 controls are now flattened to a space, like the
ASCII controls. A Message-ID holding one of them is spelled with a space in
the frontmatter, as VT and FF already were. -
The opt-in direct write folds long
Subject:andTo:lines
(#622). A long
recipient list or ASCII subject could pass the 998-octet line limit.To:
folds after a comma,Subject:at a space, and a subject folding cannot bring
under the limit goes out as encoded words. Headers that fit are unchanged byte
for byte. Atoaddress over 254 octets, the SMTP path limit, takes the GUI
path, because folding cannot split an address. -
reply_emailandforward_emailno longer say the send keystroke fired
when the GUI flow timed out
(#550). After
a 90-second timeout of the send flow, both tools reported "the send keystroke
was already dispatched", but the script had not finished, so the keystroke may
not have been pressed. A timeout now gets the same statementcompose_email
already made: the keystroke may or may not have fired, the send state is
UNKNOWN, NOT retrying, check the Sent mailbox, Outbox, the original thread and
any leftover compose window. A failure after the keystroke (POSTDISPATCH) keeps
its wording unchanged. Neither tool retries, and the error's classification is
unchanged. -
TemplateExtractorTestsno longer fails on a loaded machine
(#502).
testTheDataShapeBackstopIsBoundedAndSharesTheRedactionPatterntimed two
1,024-bytelooksLikeDatascans with the wall clock and required them to
finish within 0.2 s; at a load of about 160 they took 0.32 s and the suite
failed, although the healthy cost is 5–6 ms. The timing now uses a monotonic
clock and the 5 s ceiling of the adversarial test in the same file, with the
elapsed time in the failure message. The deterministic guard (nothing over
1,024 bytes is scanned) is unchanged. Test-only change. -
LogShowRunnerTestskeeps its timing checks clear of machine load
(#468).
The tests time the real spawn/read/terminate/reap path with a monotonic
clock instead of the wall clock. The grandchild-holds-the-pipe test was the
tight one: with a 3 s hold against a 2.5 s ceiling, the healthy path (about
1.3 s) had about 1.2 s of headroom, and the broken read-until-EOF design
(3 s) was only 1.7 s away from it. The grandchild now holds the pipe 20 s
and the ceiling is 10 s, so the two outcomes are far apart; the orphaned
sleepis killed when the test ends.
The two endless children areexec yes <line>instead of a shell
while true; do echo ...; doneloop, so they block on a full pipe instead of
spinning a core. Test-only change. -
The osascript fixtures in two test files refuse the known ways of addressing an application
(#572).
ComposeCleanupSheetTestsandPostIdentificationCleanupTestsrun fragments
cut out of production scripts through/usr/bin/osascript, and at most a check
for the literaltell applicationkept them away from Mail;tell app "Mail",
… of application "Mail"andactivate application "Mail"passed it. Every
osascript run in those two files now checks the exact text it executes with
OsascriptFixtureGuard, which removes comments and empties string literals
(reading Unicode scalars and¬continuations) and then refuses the words
app,application,processin any case, raw«…»codes,|…|identifiers,run script,
do shell script,load script,store script,open locationanduse
statements. It is a deny list, not a proof; a false positive only fails a test.
Test-only change. -
Timing CSV: script marks stay with the run that produced them
(#483). The
marks a script sends back were kept in one process-wide buffer. The upload
trigger's marks wait there across anawait, so a secondcreate_draftrun, or
acompose_emailtaking the whole buffer, could take them and write them under
the wrongrun_id. Inside a run the marks now stay with that run, and marks
the run does not take are dropped with it. The shared buffer is left for calls
outside a run, where the only script that sends marks iscompose_email's,
which captures and takes them in one actor job. This only touches diagnostics,
and only withCHE_MAIL_COMPOSE_TIMING_CSVset. -
The osascript fixtures in four more test files use the shared guard
(#617). Every
osascript run inClassificationTrashScriptTests,ComposeSignatureScriptTests,
DraftIDBaselineTestsandRecipientReceiptMetadataFailureTestsnow checks
the text it executes withOsascriptFixtureGuard. Handlers that really use the
Foundation bridge pass through an explicit allowance:use framework "Foundation",use scripting additions,current application'sfollowed by a
closed list of the names these handlers use, and three piped words.NSPredicate
passes only with the one format string they use, as the whole argument, because a
format string can run code. Any other class-shaped name, selectors by name, and the ways to name a class
in a string are refused. Handlers a test does not call lose theirtell applicationblocks before the script runs, and a block that never closes is
refused instead of dropping the rest of the script. The list bounds the class names a fixture
can write, not what the methods of those classes do: they can read and write
files and fetch URLs.OsascriptFixtureGuardScanTestsscansTests/, so a new osascript run that
skips the guard fails a test; the two helpers gated byCHE_MAIL_LIVE_TESTare
listed by name with their reason. Test-only change. -
A server built in a test can take an account mapping
(#612).
CheAppleMailMCPServer.initgained an optionalaccountMapping, passed to
EnvelopeIndexReader, so a handler test over a fixture index no longer reads
the developer's AccountsMap.plist. Without it the server behaves as before. -
The six ways around the direct-write guard tests now fail a test
(#492). A new
outcome test has Mail apply the read repair 0.6 s later, so looks that do not
wait, as with a declaredTaskthat turns the sleeps into nothing, use up their
tries. The timed trigger script has to equal the pinned untimed one plus its
marks, and the store is opened and written in one place. Each evasion was made
in the source and turned a test red. Test-only change; the frozen text is
untouched. -
More timing assertions kept clear of machine load
(#611). The
four assertions left over from #502 use a monotonic clock and a 5 s ceiling.
RedactionTestsalso grew its inputs so that the ceiling can still catch a
quadratic scan: with the pattern's lookbehind removed, a scan took 0.6 s on
8,192 characters, which a 5 s ceiling would miss, and 9.4 s on 32,768.
Test-only change. -
The direct-write path's outcomes after the write are tested without Mail
(#484).
DirectDraftPathnow reaches Mail through a small protocol, and takes the OS
version and the account lookups as settable values. No behaviour changes, and
the code after the write is untouched.DirectDraftPathOutcomeTestsruns the
real path and the realDraftStoreWriteragainst a test SQLite store with a
stand-in for Mail: upload confirmed, upload not confirmed in time, failed
trigger rolled back, failed trigger after Mail already uploaded, failed trigger
that cannot be rolled back, and the read repair, each with its outcome code and
directstep sequence. Two new tests take the timing CSV'sflockfrom a
separate process. These show the branches, not what the real Mail does. -
The stdio probe is pinned to
initialize
(#623). The
probe keepsHOMEon its environment allow list, so a tool call through it
could reach the real Mail data. A new test scans its own source and fails if
any JSON-RPC method other thaninitializeis written there, and its message
lists what to inject first. The scan is textual, so a frame assembled from a
variable gets past it. The injection points stay deferred until a test needs
them; this is test code only. -
The stdio shutdown probe starts with an allow-listed environment and checks its own assumptions
(#578). The
probe now starts with a small allow-listed environment (PATH,HOME,
TMPDIR,USER,LOGNAME,DYLD_*), so switches such as
CHE_MAIL_EXPERIMENTAL_DIRECT_DRAFTorMAIL_APP_INTEGRATION_TESTSno longer
reach it. A probe that never started is reported without writing to its stdin.
A new canary fails whenLIBDISPATCH_COOPERATIVE_POOL_STRICTstops narrowing
the cooperative pool to one thread, which would silently turn the strict
shutdown tests into ordinary-pool tests.StdioProbeBuildPlancompares
resolved paths, so a checkout reached through a symlink (/tmpis one) finds
its link command. Test-only change. The probe still fakes onlyscriptRunner
andrefusal, because it sends nothing pastinitialize
(#623 tracks the
rest).
Documentation
r-must-direct-db.mdno longer teaches the banned stderr call
(#553). Both
Hybrid pattern examples used the non-throwingFileHandle.write(_:), which
NoNonThrowingStderrWriteGuardTestsforbids because it aborts the process on
a bad descriptor; they now useDiagnostics.emit. Stalefile:line
references became symbol names.