Skip to content

#566: forwarding by a rule, on a Microsoft account's server - #841

Draft
kartas39 wants to merge 48 commits into
UCSLabs:mainfrom
kartas39:566-forward-server
Draft

kartas39 wants to merge 48 commits into
UCSLabs:mainfrom
kartas39:566-forward-server

Conversation

@kartas39

@kartas39 kartas39 commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Builds on #787. Part of #566; it doesn't close it. A draft until that PR is merged.

Narrower, as asked on #765: forwarding on the server only. Forwarding for other accounts comes in its own PR.

What changes for the person using MailCraft

  • A rule's actions have Forward to, Forward as an attachment to and Redirect to. Each has an address line with the list of recipients under it, as a meeting's attendees do. Whole addresses, at most 10 people in all, the Exchange Online limit (Exchange Online limits, "Forwardee limit").
  • On a Microsoft account, such a rule is kept on the server: Keep on the server is ticked and greyed. The server forwards the mail whether MailCraft is open or not.
  • The rule never runs on this computer. Run Rules Now leaves it out, and Run Rule Now is greyed for it.
  • Until the server has the rule (the permission to change the server's rules isn't given yet, or the server refused it), its row says it isn't running, and why.
  • For accounts whose rules stay on this computer (IMAP, Exchange server, this computer), the three actions are greyed, with the reason in the tooltip.
  • A work account's rule that forwards outside the account's domain shows a grey note: the organisation may not allow it, and then the sender, not the owner, gets the bounce (Control external email forwarding).
  • Forwarding rules made in Outlook on the web are read whole and can be edited. Before, they showed as rules with parts MailCraft doesn't know.
  • An agent asks the owner as for sending (send) before it makes, switches on or changes a forwarding rule, and before any change to the same account's server rules while one is switched on (the question names it). The same for an undo or redo that leaves one switched on.
  • The menu of a rule's action is tall enough to show all 13 actions without scrolling.

A work account's rule that forwards, and the greyed actions on an account whose rules stay on this computer, in light and dark:

Light Dark
A work account's rule that forwards, light A work account's rule that forwards, dark
Greyed forwarding actions on an account whose rules stay on this computer, light Greyed forwarding actions on an account whose rules stay on this computer, dark

How it was checked

  • cargo xtask ci passes on 704e8b6.

  • Tests: crates/engine/src/cmd/rules_forward_tests.rs, crates/net/src/graph/rules_tests.rs, crates/ui-egui/src/forms/rules/forward_tests.rs, crates/ui-egui/src/forms/rules/keep_tests.rs.

  • cargo xtask ci passes

  • A crash or data-loss fix has its regression test

  • "Allow edits by maintainers" is ticked (the box beside Create pull request)

  • I have signed the CLA, or will by commenting on this pull request

Not changed

  • Forwarding by a rule for IMAP and Exchange server accounts, from this computer while MailCraft is open: the next PR.
  • Loops: Microsoft's server forwards a message by rules once at most (the same limits page, "Number of times a message is redirected"), so MailCraft adds nothing for them.

Human-reviewed, AI-assisted, nobody's mailbox harmed.

…d actions, and a desktop alert

- Conditions: from and sent to people, sent only to me, my address in To or Cc, subject or body,
  a header, sensitivity, size, a meeting invitation, an automatic reply, a category, a flag, the
  days received; several words or addresses in one. Each can be an exception (Except if).
- Actions: copy to folder, delete permanently, flag with a due day, clear the flag, clear
  categories; a desktop alert beside Stop processing more rules.
- On a Microsoft account the server keeps what it can; the rest stays on this computer and says
  why. Rules made in Outlook with these parts are shown whole.
- Agents: rules.add takes the new parts and refuses wrong or too many; making, switching on or
  running a rule that deletes for good asks as a delete.
- Also fixed: a Graph copy then delete before Send/Receive lost the message when the copy was
  refused; rules.add cut a rule's parts past 20.

Human-reviewed, AI-assisted, nobody's mailbox harmed.
- Run Rules Now reads a calendar part for "is a meeting invitation" only when it is small enough
  to be shown, as the reading pane does.
- An agent's question before Run Rules Now names the rules that delete mail permanently, also
  when the run files mail onto another server.
- The test of a loaded rule that moves mail to an Outbox matches the message again, and shows
  the rule acting on an ordinary folder.
- The Graph round trip checks that sizes go up in kilobytes.

Human-reviewed, AI-assisted, nobody's mailbox harmed.
…nged (code scanning read their fixed clock as a nonce)

Human-reviewed, AI-assisted, nobody's mailbox harmed.
…ge isn't an invitation; a rule that can't act deletes nothing

- "Is a meeting invitation" can't be told of a message whose calendar part wasn't brought in
  (one too large to be read): a rule with it as a condition or an exception leaves the message
  alone, as for a body not here yet.
- A rule with no conditions or with parts this version doesn't know acts on nothing, so the
  agent gate doesn't count it as one that deletes mail permanently, nor names it.

Human-reviewed, AI-assisted, nobody's mailbox harmed.
…t for good is asked as a delete; before Run Rules Now the question says which rules copy and which move

A yes to the question about sending alone made such a rule: the Delete grant was asked only
when Send was allowed in advance. Now it is asked as a delete until that is allowed, once, and
the question names the server and the deleting.

Human-reviewed, AI-assisted, nobody's mailbox harmed.
…e; the MCP doc says when one question covers both grants

Human-reviewed, AI-assisted, nobody's mailbox harmed.
…owhere to go yet, too

A copy into a folder the server hadn't listed let the original's delete go first; the copy
then went from a server id that was gone, and a refusal lost the message on both sides.

Human-reviewed, AI-assisted, nobody's mailbox harmed.
…count puts nothing on another server

Human-reviewed, AI-assisted, nobody's mailbox harmed.
…or good is kept on this computer when refused

A copy waiting to be made on another account's server (Microsoft or IMAP, a shared mailbox too)
was taken away when refused, as if its original were still here. Deleted for good meanwhile, by
the owner or by a rule that copies and then deletes, the message was then lost on both sides.
Now the placement names its source, and a refused copy whose source is gone stays in Imported.

Human-reviewed, AI-assisted, nobody's mailbox harmed.
…nother account, and a refused copy brings the original back

The original's delete on its own server (IMAP, Microsoft, Exchange server) is held while a copy of it
waits to be made on another account's server. A copy refused or called off puts the original back
where its server has it, from what was kept of it; a copy made lets the delete go. An original that
can't be put back (on this computer, its folder gone here, its mailbox numbered anew) leaves the copy
kept on this computer, as before.

Human-reviewed, AI-assisted, nobody's mailbox harmed.
…e rule beside it that deletes for good

When rules.add, rules.fromMessage, rules.enable, rules.keepOnServer, rules.move or rules.remove is
asked as a delete because a rule switched on here deletes mail for good for the same mail, the
question names that rule (at most five) and says why. The condition is one function for the gate
and the text, as the rules window's redesign has it for rules.edit.

Human-reviewed, AI-assisted, nobody's mailbox harmed.
…to another account

Human-reviewed, AI-assisted, nobody's mailbox harmed.
…box is opened again, and a copy moved on still holds it

What a held delete keeps of the original is where and how it lay; its text and files come back
from the copy, which names them for the mailbox file (a message kept with a delete is written
without the names of content kept on disk, so after a reopen it came back empty, and its next
move would have deleted the server's whole original). The same for a refused copy within a
Microsoft or Exchange server account. A copy moved on into a third account before it was made
still names its source, so the delete keeps waiting for it.

Human-reviewed, AI-assisted, nobody's mailbox harmed.
… a copy moved on

Human-reviewed, AI-assisted, nobody's mailbox harmed.
Human-reviewed, AI-assisted, nobody's mailbox harmed.
…here it lay

A message moved out of an IMAP account into a Microsoft account, made there, then copied into a
third account and deleted for good, had both deletes held; a refused copy brought it back on the
Microsoft account and again in the IMAP account, there with the Microsoft server's id. Now it is
put back once: on the Microsoft account it lay in, and the IMAP original goes as the move meant.
An IMAP account's message put back carries no Microsoft server id.

Human-reviewed, AI-assisted, nobody's mailbox harmed.
…list has its say once the message is fetched whole

On a Microsoft, JMAP or Exchange server account, new mail comes as headers and a preview. A rule
on this computer that reads the text, a header, the size or whether it is a meeting invitation
couldn't tell, and nothing ran it again after the fetch. Now the rules that couldn't tell wait with
the message (Message::rules_waiting, in the order they ran, with the folder they left it in) and
run once it is fetched (graph_mail::apply_graph_fetch, which the JMAP and Exchange fetches go
through too). A rule that acted on arrival isn't run again; a delete for good that waited on an
earlier stop rule that couldn't tell goes once that rule doesn't apply. A message moved meanwhile
is let alone. file-format-parity.md says what an older build does with the new rule parts.

Human-reviewed, AI-assisted, nobody's mailbox harmed.
…f Microsoft, and keeps the copy when the original was deleted on its server meanwhile

Small check of 54263e8:
- Deleted on a phone while its delete for good waited for a copy: the delta's removal (or a
  fresh listing without it) is now noted on the held delete (graph_down::there_still), so a
  refused copy doesn't put the message back as one the server no longer has, to be swept away
  with the refused copy already taken. It comes back from the IMAP account it was moved there
  from, or the copy stays in Imported.
- A Microsoft message being moved out into an IMAP account, not put there yet: a refused copy
  brings it back as that server's message, and its copy there isn't deleted.
- Put back on the IMAP server, the deletion of the Microsoft original it was moved from goes
  as the move meant it to, and a refusal of that deletion adds no second message.

Human-reviewed, AI-assisted, nobody's mailbox harmed.
…d once, not once a word

Human-reviewed, AI-assisted, nobody's mailbox harmed.
…a day, or a flag or the categories cleared has parts this version doesn't know

Human-reviewed, AI-assisted, nobody's mailbox harmed.
…han it can keep, and the box for the server judges its exceptions as they are

Human-reviewed, AI-assisted, nobody's mailbox harmed.
# Conflicts:
#	crates/ui-egui/src/forms/rules/keep_tests.rs
#	docs/file-format-parity.md
…ount keeps the message when its original was deleted on the server meanwhile

Human-reviewed, AI-assisted, nobody's mailbox harmed.
…wered "no such message" while its original waits to be deleted for good keeps the message

Human-reviewed, AI-assisted, nobody's mailbox harmed.
…umber for is refused, rather than putting one of them after the locked rule on the server

Human-reviewed, AI-assisted, nobody's mailbox harmed.
Human-reviewed, AI-assisted, nobody's mailbox harmed.
…where they put it, and after "no such message" the original's delete still goes

Human-reviewed, AI-assisted, nobody's mailbox harmed.
…e for good is called off again

A copy within the account answered 404 confirms the message nowhere: the
server may still have the original (the copy's folder there gone), and the
copy here may be only its headers. So the held delete is dropped, the copy
is kept in Imported when it is still in this account, and one the owner moved
on stays where they put it. Tests cover a copy moved on and refused with the
original deleted on a phone, and one moved on with the original not deleted.

Human-reviewed, AI-assisted, nobody's mailbox harmed.
Conflicts: an undo's approval keeps both causes for Delete, mail the undo
takes away (UCSLabs#473) and a rule switched on that deletes for good (UCSLabs#566); the
docs keep both sides' rows.

Human-reviewed, AI-assisted, nobody's mailbox harmed.
…s answer stays where it was put

Human-reviewed, AI-assisted, nobody's mailbox harmed.
… waits is taken as a refusal

The server may still have the original (the copy's folder there gone) or
not (deleted on a phone). Either way no copy was made, so the original is put
back as on a refusal: where the server has it, or in Imported once the server
says it is gone. Before, the delete was only called off and the original,
still on the server, wasn't shown here again. A test covers the copy's folder
gone, with the original fetched whole or only its headers.

The release note says only a copy moved onto this computer or into another
account stays where it was put; the threat model says an undo leaving a rule
on that deletes permanently asks delete.

Human-reviewed, AI-assisted, nobody's mailbox harmed.
… Graph answers rebuild the index

Taking that answer as a refusal (c409d88) put the original back as the
server's, and an owner's move of it, or a server index built before, could
then lose it. The copy arm is back as it was at 025f461: the delete is called
off and the copy kept in Imported; a message the server still has stays there
and shows again once its folder is read afresh, as the comment now says.

The answers to a Microsoft account's message changes now reset the index of
its server's mail, as an Exchange server account's do: an original put back
after a refusal, with the index built before without it, missed the phone's
delete in the next listing and was swept away later. Tests: a copy of mail not
here whole answered "no such message" deletes nothing there; that put-back
original is kept in Imported.

Human-reviewed, AI-assisted, nobody's mailbox harmed.
…ce; the copy note names "no such message"

The index reset after a Microsoft account's message answers (960fdc0) also
fixes a bug on main: a copy listed after its answer showed twice in its folder
when the index was built between the copy and the answer. The release note for
a copy then deleted permanently names the "no such message" answer too.

Human-reviewed, AI-assisted, nobody's mailbox harmed.
A search by name and New Rule over the rules; each rule with its switch,
where it is kept, Move Up and Move Down, a menu (Run Rule Now, Keep Rule on
Server, Delete Rule) and an arrow that shows what it does. New Rule opens
the new rule's page in the lists' place, its conditions, exceptions and
actions each in a box, with Add Rule and Cancel. The dialog moves by its
title, is sized by its edges and corners, and keeps its size.

Every rule moves with its arrows, one the server doesn't let be changed
too. Its new place is told to the server first; a refusal (a 403 too, or a
yes that leaves it where it was) is that rule's alone, stops the rest of
that upload, and puts it and the places that were to follow it back where
the server has them, said in words. The arrows are greyed only at the ends
of a list and past a rule still to go to the server.

A rule `rules.add` makes without `account` is the account in view's (a
shared mailbox's owner's, where the window now opens too), as the window's
is, and the agent's question names that account; it was for every
account's mail. A rule made for the placeholder of an empty mailbox goes to
the first account added, with its standard folders; it was dropped.

Human-reviewed, AI-assisted, nobody's mailbox harmed.
Edit Rule, in a rule's menu, opens the rule's page filled in with what the
rule is, with Save and Cancel; it is greyed, with why, for a rule the server
doesn't let be changed, one with parts MailCraft can't show, one the server
is still making and one the page can't show. `rules.edit` changes the rule
in place: it stays for its account, where it is kept, switched on or off and
in its place. One on a Microsoft account's server is sent there whole at the
next Send/Receive (PATCH with its name, conditions, exceptions and actions),
and what the server can't keep is said on the page and not saved. An agent's
change asks as making that rule would, and names the rules beside it that
delete for good.

Human-reviewed, AI-assisted, nobody's mailbox harmed.
…indow's layer is named, not salted

What a rule looks for and what it does went to the Rules window in English in
every language. The conditions, exceptions and actions, the words that join
them, a move's folder, the stop and the alert now go through the catalogues
(Condition::describe_in, Action::describe_in, Rule::looks_for_in), with fuzzy
drafts in the five; the English that rules.list and the agent's question read
is what it was. A rule's "When" has a context of its own, as German says
"Wenn" there and "Wann" for a meeting's time.

sized_window's and sized_layer's `salt` parameter is `name`: CodeQL read the
Rules window's name as a hard-coded salt.

Human-reviewed, AI-assisted, nobody's mailbox harmed.
…nto Edit Rule

Human-reviewed, AI-assisted, nobody's mailbox harmed.
nl.po: the two rule strings UCSLabs#780 translated take its translation.

Human-reviewed, AI-assisted, nobody's mailbox harmed.
…esktop alert then; the copy marker's time is a stamp

A rule on this computer that reads what a server's list of new mail doesn't give (the text, a
header, the size) acted once the message was fetched whole, but never showed the desktop alert it
asks for. It now marks the message for one, the fetch names it, and the window shows it once the
download is over, after the Send/Receive under way if there is one, and not for a message the
run's end told of already as new mail.

copy_message_marked's parameter is a stamp, not a nonce: code scanning took the test clock that
reaches it for one.

Human-reviewed, AI-assisted, nobody's mailbox harmed.
… in one Send/Receive; what was told isn't kept past a restart

Human-reviewed, AI-assisted, nobody's mailbox harmed.
…il is downloaded, main's translations) into the Rules window

Human-reviewed, AI-assisted, nobody's mailbox harmed.
… in Rules for

Rules from before a rule was for one account still run on every
account's mail, now after the server's rules and before the account's
own of this computer, and move among themselves. They are no longer in
each account's list; New Rule is greyed under All accounts.

Human-reviewed, AI-assisted, nobody's mailbox harmed.
…new head into Edit Rule

Human-reviewed, AI-assisted, nobody's mailbox harmed.

# Conflicts:
#	ROADMAP.md
#	crates/ui-egui/src/forms.rs
…dit Rule meets All accounts

A rule under All accounts has For One Account and the accounts in its
menu (rules.forAccount): it then runs on that account's mail alone, kept
on this computer and first of its rules there. One that moves or copies
mail to another account's folder opens on the rule page with no folder
for it, and is given as it is saved (rules.edit with account); Cancel
leaves it under All accounts. Edit Rule is greyed for such a rule.

Human-reviewed, AI-assisted, nobody's mailbox harmed.
…l accounts

A rule made before the first account is that account's once it is
added, not one for every account: the window's first line no longer
names All accounts then.

Human-reviewed, AI-assisted, nobody's mailbox harmed.
…o Edit Rule

Human-reviewed, AI-assisted, nobody's mailbox harmed.

# Conflicts:
#	crates/ui-egui/src/forms/rules/page_tests.rs
Edit Rule showed a folder deleted since as it was, and Save was refused
after it; it now shows Choose a folder, and Save waits for one. Given
to an account, a rule keeps that account's own folders even where the
list of folders leaves them out.

Human-reviewed, AI-assisted, nobody's mailbox harmed.
A rule can forward mail to people, forward it as an attachment or redirect it (Graph's
forwardTo, forwardAsAttachmentTo and redirectTo; whole addresses, at most 10 in all). Only
a Microsoft account's server forwards: such a rule is kept there or not made, never runs on
this computer (Run Rules Now leaves it out) and waits for permission to change the server's
rules as any rule does. The server's own forwarding rules are read whole and can be changed.
The three actions are greyed, with why, for accounts whose rules stay on this computer. A
work account's rule that forwards outside its domain says the organisation may stop it. An
agent asks as for sending before such a rule is made, switched on or changed, and before any
change to the same account's server rules while one is switched on.

Human-reviewed, AI-assisted, nobody's mailbox harmed.
@coderabbitai

coderabbitai Bot commented Nov 5, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant