Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Local outbox #5884

Closed
11 of 12 tasks
Tracked by #5438 ...
ChristophWurst opened this issue Dec 20, 2021 · 9 comments · Fixed by #6190
Closed
11 of 12 tasks
Tracked by #5438 ...

Local outbox #5884

ChristophWurst opened this issue Dec 20, 2021 · 9 comments · Fixed by #6190

Comments

@ChristophWurst
Copy link
Member

ChristophWurst commented Dec 20, 2021

Feature Request

Instead of sending outgoing messages directly to SMTP and IMAP we should store them in a local outbox and try to push them from there afterwards.

This gives us new abilities

  • At a temporary server issue the message can remain in the outbox, a background job can try to resend the message later automatically. The user doesn't have to convert to draft and send the message themselves.
  • We can implement Undo sending an email #5438 in a way that messages are still sent when the user closes their tab before the expiration of the fake undo timer because then the message is on the server and a background job will pick it up.
  • We can implement Send scheduled / time-controlled mail #1626 if we add an optional send time for a message. A background job will pick up the message when the time is reached.

It should be sufficient to have one outbox per user account. We don't need a separate outbox for every Mail account.

Summary

Store messages before sending them to SMTP.

Implementation

Critical bugs and other follow-ups

These chunks do not make an atomic change. Let's use a feature branch for this whole outbox feature where the changes from above are merged into and then one final PR that integrates it back into main.

@miaulalala
Copy link
Contributor

miaulalala commented Jan 25, 2022

Some things:

  1. remove is_mdn
  2. Getting the local mailbox messages - separating headers and body as we did with envelopes because it could be a lot of data
  3. Attachments handling is super unclear atm.
  4. Replied to message - get message from DB
  5. add alias_id field to migration

@miaulalala
Copy link
Contributor

Save endpoint will remove message from draft mailbox (if possible).
Undo send endpoint that will convert message back to imap draft.

@st3iny
Copy link
Member

st3iny commented Jan 25, 2022

Some more thoughts:

  1. Continue to use old MDN endpoint -> skip outbox

@ChristophWurst
Copy link
Member Author

Attachments handling is super unclear atm.

What part of it? As per #5885 we either have to serialize or normalize the data into two tables.

@miaulalala
Copy link
Contributor

Attachments handling is super unclear atm.

What part of it? As per #5885 we either have to serialize or normalize the data into two tables.

More the frontend part and the way we offer different attachments in the first place. I am using the localAttachments table for local attachments in the backend.

@ChristophWurst
Copy link
Member Author

ChristophWurst commented Feb 17, 2022

@jancborchardt @nimishavijay we found a small issue with this feature.

For context, this is the base work for undo sending and scheduled sending. Moreover it will make sending emails more snappy, allow automatic retries when sending fails and also do a large chunk of work that we'll need for the revised draft handling.

What we realized is that we do have two options to handle cloud or forwarded attachments of messages that might not be sent immediately.

  1. Keep only a reference to the cloud file or forwarded attachment. Then we will run into the issue that the attachment a user picks might not be the one that is actually sent, because the file can change until the message gets out. Even worse, the cloud file or the original message with the attachment could be deleted and then we can't send the message.
  2. Copy/download the files when the message is added to the outbox. This makes us independent of time, because the file doesn't depend on changes in your cloud files, nor the existence of the original message of which you forward an attachment. The "downside" is that if a user wants to always attach the latest version this won't be possible. So maybe this needs some hints in the UI. But then users could share that same cloud file via link.

From a technical PoV we'll have an easier life if we go with 2). But for completeness I wanted to have you in the loop on this design decision.

@nimishavijay
Copy link
Member

  1. Keep only a reference to the cloud file

If someone is sending an attachment using a cloud file link, then the sender would know that it could be changed by the time the recipient opens it, right? It is expected behavior when you attach, for eg. a link to a Google Doc, so it should be all good.
If you want to send the current state, you can explicitly attach a saved copy.
So option 1 works :)

@ChristophWurst
Copy link
Member Author

I am not talking about share links. It's only about file that get attached. The question is when we should take the copy of the attached file when a message is sent at a later point in time.

With 1) we take a copy at the time of the actual sending. With 2) we take a copy at the time of writing.

I've updated my post above to reflect that we'd strongly lean towards option 2) because 1) has too many potential side effects and errors to catch.

@jancborchardt
Copy link
Member

@ChristophWurst so Nimisha and I just talked about this and cleared up the confusion, and we agree with option 2. :)

The "downside" is that if a user wants to always attach the latest version this won't be possible. […] But then users could share that same cloud file via link.

Exactly that ^, so there’s no downside.

We think it is a bit confusing that there are 2 separate entries to share stuff from Nextcloud, and we’ll open a separate issue about how to best combine that.

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