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

As a user I want have a validation before sending the request, or at least manage (display a nice error message) when size is exceeded. #537

Open
fabienmoyon opened this issue Mar 11, 2022 · 6 comments

Comments

@fabienmoyon
Copy link
Member

current

User is able to send an email over the size limitation with a multiple attachments

Actual Result

User is able to send an email with multiple attachments that over the size limitation.
The email is saved to the Sent mailbox but not actually delivered to the recipient

Relate to this one #258

Peek_2020-12-21_12-02

Expected Result

It should return a warning for over the size limitation and doesn't allow to send the email

As a user I want have a validation before sending the request, or at least manage (display a nice error message) when size is exceeded.

expected

James now allows to configure the maximum size for emails (sum of all attachments) allowed and fails when exceeded.

In the composer have a validation before sending the request, or at least manage (display a nice error message) when size is exceeded.

Related to https://ci.linagora.com/linagora/lgs/k8s/indus-team-backlog/-/issues/943#note_419214

@fabienmoyon fabienmoyon added this to the Polish sprint milestone Mar 11, 2022
@alagane alagane self-assigned this Mar 14, 2022
@alagane
Copy link
Member

alagane commented Mar 14, 2022

I tried locally and got an email from James
image

What it should do is check the total file size before sending the mail asking if we are sure we want to send it, and it may fail?

@chibenwa
Copy link
Member

Jmap rfc-8620 allow knowing max supported email size. Frontend can try detecting when this limit is exceeded. Like "sum attachment > max size". And the say " mail too big, please consider other means to share tgese files".

However it's not exact science as it do not account for base64 encoding, text bodies, headers, mime stuff, etc. Thus more importantly the underlying JMAP exception needs to be handled. Composer reopened with an explanation.

I am unsure how your james server is configured. It looks like no limit is set in the jmap layer but only at the mail processing layer.

@chibenwa
Copy link
Member

So you :

  • must configure jmap on james to enforce maximum size of submitted emails
  • must handle the exception during the send, explain and reopen the composer
  • could check jmap session to see what you are allowed to send and prevent submitting too big mails.

Sorry written from mobile, if you need detailed pointers (conf / jmap) feel free to ask.

@fabienmoyon
Copy link
Member Author

And the goal of this issue it to validate and display to the user before sending the message that the max size is exceeded

@tanandy
Copy link
Contributor

tanandy commented Mar 14, 2022

And the goal of this issue it to validate and display to the user before sending the message that the max size is exceeded

True as Benoit mentionned last time and you today, we need both client and server side validation.

No need to call the server if the size is already higher that what we allow in client

Note: you must also have to handle answer from the server (unexpected or not) correctly in the ui (in this issue, or create another one)

@chibenwa
Copy link
Member

Set email.send.max.size in jmap.properties, eg email.send.max.size=20M

CF https://github.com/apache/james-project/blob/master/server/apps/distributed-app/docs/modules/ROOT/pages/configure/jmap.adoc

Then in JMAP you can read the session object to retrieve that value on client side: https://jmap.io/spec-mail.html#additions-to-the-capabilities-object

maxSizeAttachmentsPerEmail: UnsignedInt The maximum total size of attachments, in octets, allowed for a single Email object. A server MAY still reject the import or creation of an Email with a lower attachment size total (for example, if the body includes several megabytes of text, causing the size of the encoded MIME structure to be over some server-defined limit).

Note that this limit is for the sum of unencoded attachment sizes. Users are generally not knowledgeable about encoding overhead, etc., nor should they need to be, so marketing and help materials normally tell them the “max size attachments”. This is the unencoded size they see on their hard drive, so this capability matches that and allows the client to consistently enforce what the user understands as the limit.

And finally the error that should be returned when the size is exceeded is a tooLarge SetError as defined in https://jmap.io/spec-core.html#set

Re-reading James tests this morning I realize that we sadly don't use the specific tooLarge error set but rather relies on the generic invalidArguments. Cf https://github.com/apache/james-project/blob/413983cebf14265c5b18ecb682faecff503a7ba7/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/EmailSetMethodContract.scala#L1422 . We'll fix that.

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

No branches or pull requests

4 participants