{"record":{"id":"83be352f970c0df7","repo":"flowable/flowable-engine","slug":"failed-to-set-send-date","errorCode":null,"errorMessage":"Failed to set send date","messagePattern":"Failed to set send date","errorType":"exception","errorClass":"FlowableMailException","httpStatus":null,"severity":"error","filePath":"modules/flowable-mail/src/main/java/org/flowable/mail/common/impl/jakarta/mail/JakartaMailFlowableMailClient.java","lineNumber":248,"sourceCode":"            fromAddress = from;\n        } else { // use default configured from address in defaults configuration\n            fromAddress = defaultsConfiguration.defaultFrom();\n        }\n\n        try {\n            message.setFrom(createInternetAddress(fromAddress));\n        } catch (MessagingException e) {\n            throw new FlowableMailException(\"Could not set \" + fromAddress + \" as from address in email\", e);\n        }\n    }\n\n    protected void setSentDate(MimeMessage message) {\n        try {\n            if (message.getSentDate() == null) {\n                message.setSentDate(new Date());\n            }\n        } catch (MessagingException e) {\n            throw new FlowableMailException(\"Failed to set send date\", e);\n        }\n    }\n\n    protected void setContent(MimeMessage mimeMessage, MailMessage message, String charset) {\n        String text = message.getPlainContent();\n        String html = message.getHtmlContent();\n        Collection<DataSource> attachments = message.getAttachments();\n        boolean attachmentsExists = attachments != null && !attachments.isEmpty();\n        if (html == null && text == null) {\n            throw new FlowableIllegalArgumentException(\"'html' or 'text' is required to be defined when sending an email\");\n        }\n        if (html == null && !attachmentsExists) {\n            try {\n                mimeMessage.setText(text, charset);\n            } catch (MessagingException e) {\n                throw new FlowableMailException(\"Could not create text-only email\", e);\n            }\n        } else {","sourceCodeStart":230,"sourceCodeEnd":266,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-mail/src/main/java/org/flowable/mail/common/impl/jakarta/mail/JakartaMailFlowableMailClient.java#L230-L266","documentation":"JakartaMailFlowableMailClient.setSentDate() wraps MessagingException thrown while inspecting or setting the sent date on a MimeMessage. If the message has no sent date, it sets the current Date; either the getSentDate() or setSentDate() call can throw MessagingException, which is wrapped in FlowableMailException. This indicates a low-level failure in the Jakarta Mail message construction, not a user data problem.","triggerScenarios":"Calling createMimeMessage() with a MailMessage whose MimeMessage.getSentDate() or setSentDate(new Date()) throws MessagingException — typically due to an invalid or broken underlying MimeMessage header state or a Jakarta Mail provider failure.","commonSituations":"Corrupted or unusual message header state; Jakarta Mail provider quirks when headers cannot be parsed; rarely seen since a freshly created MimeMessage rarely fails here — usually indicates a provider or environment problem (e.g. broken mail.jar/jakarta.mail integration).","solutions":["Check the nested MessagingException cause to identify the actual header/provider failure","Verify the jakarta.mail dependency version is consistent (no mixed javax.mail/jakarta.mail artifacts on the classpath)","Ensure no custom MimeMessage manipulation occurs before send that could corrupt header state","If the nested cause is provider-specific, pin a working jakarta.mail implementation version"],"exampleFix":"// before: failure deep in mail provider\nclasspath: javax.mail-1.6.jar + jakarta.mail-2.0.jar\n// after: remove the legacy javax.mail jar so only jakarta.mail is used\nimplementation 'org.eclipse.angus:angus-mail:2.0.3'","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    mailClient.send(mailMessage);\n} catch (FlowableMailException e) {\n    if (e.getCause() instanceof MessagingException me) {\n        log.error(\"MIME sent-date failure: {}\", me.getMessage(), me);\n    }\n    throw new MailConfigurationException(\"Mail session/provider broken\", e);\n}","preventionTips":["Keep a single, consistent jakarta.mail implementation on the classpath","Do not mutate the MimeMessage between construction and send","Log nested causes so provider-level failures are visible"],"tags":["mail","jakarta-mail","messaging-exception","mime-message"],"backgroundTag":"api-request-failed","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}