Skip to content

Queue messages for SMTP before encryption - #8619

Open
link2xt wants to merge 4 commits into
mainfrom
link2xt/late-encryption
Open

Queue messages for SMTP before encryption#8619
link2xt wants to merge 4 commits into
mainfrom
link2xt/late-encryption

Conversation

@link2xt

@link2xt link2xt commented Aug 22, 2026

Copy link
Copy Markdown
Collaborator

Part of #8607, this removes the code that deletes the whole queue when the sending relay is changed, and makes queueing the mail independent of the sending address. Follow-up to #8345 in some way, this now uses QueuedMail for real.

There is a python test that was previously failing, deleting the current transport while having messages queued.

Large number of lines added is because of better types (new QueuedEncryption separate from mimefactory::Encryption) and duplicated smtp2 table with documentation.

Left for follow-up PRs:

  • Store side effects and the mail itself in a single transaction in chat::enqueue_mail. This needs refactoring location streaming code etc. that is unrelated.
  • Moving QueuedMail, QueuedEncryption and related functions from mimefactory to a separate module.
  • Cycling through transports in SMTP loop if connection to the first one fails and connecting to the last used one instead of ConfiguredAddr.

Note re performance of encryption: maybe it even makes UI more responsive because the message bubble can appear on the sending side faster as the message does not need to be encrypted yet.

Commit message Headers like From and Autocrypt are now added late, right before sending the message over SMTP. This way we advertise the latest list of transports and use the correct From address in the encrypted part even for messages queued while being offline.

BCC-self recipients are also added late.
For unencrypted messages we only want to send a copy
to the sending address, but we don't know the sending address
when queueing the message.
Adding bcc-self recipients when dequeuing the message
also makes it possible to send copies to updated list of relays.

@link2xt
link2xt force-pushed the link2xt/late-encryption branch 2 times, most recently from 026e72d to ce56911 Compare August 25, 2026 17:11
@link2xt
link2xt changed the base branch from main to link2xt/create_send_msg_jobs-row_id August 25, 2026 17:14
@link2xt
link2xt force-pushed the link2xt/late-encryption branch 2 times, most recently from d688b11 to 6809578 Compare August 25, 2026 20:23
@link2xt
link2xt force-pushed the link2xt/create_send_msg_jobs-row_id branch from e657a72 to a67a5b0 Compare August 26, 2026 14:36
Base automatically changed from link2xt/create_send_msg_jobs-row_id to main August 26, 2026 20:22
@link2xt
link2xt force-pushed the link2xt/late-encryption branch 3 times, most recently from 756d28c to 3d72fe8 Compare September 1, 2026 17:25
@link2xt
link2xt force-pushed the link2xt/late-encryption branch 8 times, most recently from b838513 to bdfd0d4 Compare September 9, 2026 05:43
@link2xt
link2xt changed the base branch from main to link2xt/refactor-ref-vec September 9, 2026 06:13
@link2xt
link2xt added this pull request to stack #8677 September 9, 2026 06:13
@link2xt
link2xt force-pushed the link2xt/late-encryption branch 2 times, most recently from 958c526 to fe41960 Compare September 9, 2026 07:55
Base automatically changed from link2xt/refactor-ref-vec to main September 9, 2026 08:34
It was incorrectly converting unused row ID to MsgId type
and selecting already known msg_id.
This is similar to mimefactory::Encryption,
but does not have email addresses for asymmetrically encrypted messages.
Queued messages don't need email addresses for public keys.
Addresses are only needed to render Autocrypt-Gossip headers.
@link2xt
link2xt force-pushed the link2xt/late-encryption branch 2 times, most recently from 8a42d9b to b9bba12 Compare September 9, 2026 08:37
@link2xt
link2xt removed this pull request from stack #8677 September 9, 2026 08:38
@link2xt
link2xt force-pushed the link2xt/late-encryption branch 2 times, most recently from 3e8fdaa to eb1c34c Compare September 9, 2026 10:11
Headers like From and Autocrypt are now added late,
right before sending the message over SMTP.
This way we advertise the latest list of transports
and use the correct From address in the encrypted part
even for messages queued while being offline.

BCC-self recipients are also added late.
For unencrypted messages we only want to send a copy
to the sending address, but we don't know the sending address
when queueing the message.
Adding bcc-self recipients when dequeuing the message
also makes it possible to send copies to updated list of relays.
@link2xt
link2xt force-pushed the link2xt/late-encryption branch from eb1c34c to 7eb324f Compare September 9, 2026 10:26
@link2xt link2xt changed the title WIP: Late encryption Queue messages for SMTP before encryption Sep 9, 2026
@link2xt
link2xt marked this pull request as ready for review September 9, 2026 10:27
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