Skip to content

Nullpointer in SMIMESupport.isMimeMessageAttachment #572

Closed

Description

@Faelean

I'm getting a NullPointer exception when trying to parse the attached mail (had to use a zip because apparently GitHub doesn't allow msg files anymore).

MSG-Datei_T24-03167.zip

        String msgFileName = ".\\assets_sjm\\T24-03167.msg";

        try (FileInputStream fileInputStream = new FileInputStream(msgFileName)) {

            Email email = EmailConverter.outlookMsgToEmail(fileInputStream);
            System.out.println("Sent Date: " + email.getSentDate());
        }

This is the StackTrace I get when using the code above and 8.12.4

Exception in thread "main" java.lang.NullPointerException: Cannot invoke "org.simplejavamail.api.email.AttachmentResource.getDataSource()" because "attachment" is null
	at org.simplejavamail.internal.smimesupport.SMIMESupport.isMimeMessageAttachment(SMIMESupport.java:212)
	at org.simplejavamail.internal.smimesupport.SMIMESupport.decryptAttachments(SMIMESupport.java:204)
	at org.simplejavamail.internal.smimesupport.SMIMESupport.decryptAttachments(SMIMESupport.java:131)
	at org.simplejavamail.internal.smimesupport.SMIMESupport.decryptAttachments(SMIMESupport.java:100)
	at org.simplejavamail.converter.EmailConverter.decryptAttachments(EmailConverter.java:257)
	at org.simplejavamail.converter.EmailConverter.outlookMsgToEmailBuilder(EmailConverter.java:251)
	at org.simplejavamail.converter.EmailConverter.outlookMsgToEmail(EmailConverter.java:228)
	at org.simplejavamail.converter.EmailConverter.outlookMsgToEmail(EmailConverter.java:220)

Activity

  1. added this to the 8.13.0 milestone on Jul 4, 2026
  2. bbottema commented on Jul 4, 2026

    @bbottema
    Owner

    Fixed by making Outlook/S/MIME conversion more lenient for malformed or unsupported signed payloads.

    When Bouncy Castle can identify the attachment as S/MIME but the liberated content is not a MIME message or multipart payload, Simple Java Mail now keeps the original smime.p7m attachment instead of trying to promote a null converted attachment.

    Example outcome:

    Email email = EmailConverter.outlookMsgToEmail(msgInputStream);
    email.getAttachments();          // contains the original smime.p7m
    email.getSmimeSignedEmail();     // null when no MIME email can be recovered
  3. bbottema commented on Jul 8, 2026

    @bbottema
    Owner

    Released in Simple Java Mail v9.0.0, which is now available from Maven Central:

    https://repo1.maven.org/maven2/org/simplejavamail/simple-java-mail/9.0.0/

    Release notes:
    https://github.com/bbottema/simple-java-mail/releases/tag/9.0.0

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions