chibenwa commented on code in PR #2624: URL: https://github.com/apache/james-project/pull/2624#discussion_r1942616577
########## server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/EmailSubmissionSetMethod.scala: ########## @@ -354,15 +354,21 @@ class EmailSubmissionSetMethod @Inject()(serializer: EmailSubmissionSetSerialize def validateMimeMessages(mimeMessage: MimeMessage) : SMono[MimeMessage] = validateMailAddressHeaderMimeMessage(mimeMessage) private def validateMailAddressHeaderMimeMessage(mimeMessage: MimeMessage): SMono[MimeMessage] = - SFlux.fromIterable(Map("to" -> Option(mimeMessage.getRecipients(RecipientType.TO)).toList.flatten, - "cc" -> Option(mimeMessage.getRecipients(RecipientType.CC)).toList.flatten, - "bcc" -> Option(mimeMessage.getRecipients(RecipientType.BCC)).toList.flatten, - "from" -> Option(mimeMessage.getFrom).toList.flatten, - "sender" -> Option(mimeMessage.getSender).toList, - "replyTo" -> Option(mimeMessage.getReplyTo).toList.flatten)) - .doOnNext { case (headerName, addresses) => (headerName, addresses.foreach(address => validateMailAddress(headerName, address))) } - .`then`() - .`then`(SMono.just(mimeMessage)) + Option(mimeMessage.getFrom) match { + case Some(from) if from.nonEmpty => SFlux.fromIterable(Map( + "to" -> Option(mimeMessage.getRecipients(RecipientType.TO)).toList.flatten, + "cc" -> Option(mimeMessage.getRecipients(RecipientType.CC)).toList.flatten, + "bcc" -> Option(mimeMessage.getRecipients(RecipientType.BCC)).toList.flatten, + "from" -> from.toList, + "sender" -> Option(mimeMessage.getSender).toList, + "replyTo" -> Option(mimeMessage.getReplyTo).toList.flatten)) + .doOnNext { case (headerName, addresses) => (headerName, addresses.foreach(address => validateMailAddress(headerName, address))) } + .`then`() + .`then`(SMono.just(mimeMessage)) + + case _ => SMono.error(new IllegalArgumentException("MimeMessage From declaration is missing")) Review Comment: ```suggestion case _ => SMono.error(ForbiddenMailFromException(...)) ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@james.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: notifications-unsubscr...@james.apache.org For additional commands, e-mail: notifications-h...@james.apache.org