Per https://github.com/chrislee35/IMAPCrypt/issues/4
When reading in a message with "This is an OpenPGP/MIME signed message (RFC 4880 and 3156)" before the first multipart header, (example)
Organization: University of W
**This is an OpenPGP/MIME signed message (RFC 4880 and 3156)**
--6Bz12SPHdLD2klMA4NBD8zn1ly5bMF07y
Content-Type: multipart/mixed; boundary="CMd4g2X27IlcaBXpXxQ2xQxYMbDN6dY54";
protected-headers="v1"
It throws an exception:
javax.mail.IllegalWriteException: IMAPBodyPart is read-only
at com.sun.mail.imap.IMAPBodyPart.setHeader(IMAPBodyPart.java:325)
at de.buelowssiege.mail.pgp_mime.gpg.GnuPGExecuter.updateHeaders(GnuPGExecuter.java:201)
at de.buelowssiege.mail.pgp_mime.gpg.GnuPGExecuter.updateHeaders(GnuPGExecuter.java:153)
at de.buelowssiege.mail.pgp_mime.gpg.GnuPGExecuter.updateHeaders(GnuPGExecuter.java:170)
at de.buelowssiege.mail.pgp_mime.gpg.GnuPGExecuter.writeBodyPart(GnuPGExecuter.java:123)
at de.buelowssiege.mail.pgp_mime.gpg.GnuPGBodyPartEncrypter.encrypt(GnuPGBodyPartEncrypter.java:89)
at de.buelowssiege.mail.pgp_mime.MimeMultipartEncrypted.createInstance(MimeMultipartEncrypted.java:92)
at de.buelowssiege.mail.pgp_mime.MimeMultipartEncrypted.createInstance(MimeMultipartEncrypted.java:67)
at org.dhs.chrislee.IMAPCrypt.encrypt(IMAPCrypt.java:344) (github.com)
My best guess is that the OpenPGP line is confusing the mimeparser somehow and when updateHeaders tries to set the Header, it throws an exception. I tried my best to figure this out on my own, but failed. Could you please help me debug this?