diff --git a/app/src/main/java/eu/faircode/email/MessageHelper.java b/app/src/main/java/eu/faircode/email/MessageHelper.java index 4da9c637b2..3e3d8eb099 100644 --- a/app/src/main/java/eu/faircode/email/MessageHelper.java +++ b/app/src/main/java/eu/faircode/email/MessageHelper.java @@ -2145,9 +2145,32 @@ public class MessageHelper { try { if (imessage instanceof IMAPMessage) { - if (body) - imessage.getContentType(); // force loadBODYSTRUCTURE - else + if (body) { + String contentType = imessage.getContentType(); // force loadBODYSTRUCTURE + + // Workaround protocol parameter missing + // Happens with Yandex and possibly other providers + boolean load = false; + try { + ContentType ct = new ContentType(contentType); + if (ct.match("multipart/signed") || ct.match("multipart/encrypted")) { + String protocol = ct.getParameter("protocol"); + if (protocol == null) + load = true; + } else if (ct.match("application/pkcs7-mime") || ct.match("application/x-pkcs7-mime")) { + String smimeType = ct.getParameter("smime-type"); + if (smimeType == null) + load = true; + } + } catch (Throwable ex) { + Log.w(ex); + } + + if (load) { + Log.w("Protocol missing content-type=" + contentType); + throw new MessagingException("Failed to load IMAP envelope"); + } + } else imessage.getMessageID(); // force loadEnvelope } } catch (MessagingException ex) {