flowable/flowable-engine · error · FlowableMailException

Failed to set send date

Error message

Failed to set send date

What it means

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.

Source

Thrown at modules/flowable-mail/src/main/java/org/flowable/mail/common/impl/jakarta/mail/JakartaMailFlowableMailClient.java:248

            fromAddress = from;
        } else { // use default configured from address in defaults configuration
            fromAddress = defaultsConfiguration.defaultFrom();
        }

        try {
            message.setFrom(createInternetAddress(fromAddress));
        } catch (MessagingException e) {
            throw new FlowableMailException("Could not set " + fromAddress + " as from address in email", e);
        }
    }

    protected void setSentDate(MimeMessage message) {
        try {
            if (message.getSentDate() == null) {
                message.setSentDate(new Date());
            }
        } catch (MessagingException e) {
            throw new FlowableMailException("Failed to set send date", e);
        }
    }

    protected void setContent(MimeMessage mimeMessage, MailMessage message, String charset) {
        String text = message.getPlainContent();
        String html = message.getHtmlContent();
        Collection<DataSource> attachments = message.getAttachments();
        boolean attachmentsExists = attachments != null && !attachments.isEmpty();
        if (html == null && text == null) {
            throw new FlowableIllegalArgumentException("'html' or 'text' is required to be defined when sending an email");
        }
        if (html == null && !attachmentsExists) {
            try {
                mimeMessage.setText(text, charset);
            } catch (MessagingException e) {
                throw new FlowableMailException("Could not create text-only email", e);
            }
        } else {

View on GitHub (pinned to d6d39ce1c6)

Solutions

  1. Check the nested MessagingException cause to identify the actual header/provider failure
  2. Verify the jakarta.mail dependency version is consistent (no mixed javax.mail/jakarta.mail artifacts on the classpath)
  3. Ensure no custom MimeMessage manipulation occurs before send that could corrupt header state
  4. If the nested cause is provider-specific, pin a working jakarta.mail implementation version

Example fix

// before: failure deep in mail provider
classpath: javax.mail-1.6.jar + jakarta.mail-2.0.jar
// after: remove the legacy javax.mail jar so only jakarta.mail is used
implementation 'org.eclipse.angus:angus-mail:2.0.3'
Defensive patterns

Strategy: try-catch

Try / catch

try {
    mailClient.send(mailMessage);
} catch (FlowableMailException e) {
    if (e.getCause() instanceof MessagingException me) {
        log.error("MIME sent-date failure: {}", me.getMessage(), me);
    }
    throw new MailConfigurationException("Mail session/provider broken", e);
}

Prevention

When it happens

Trigger: 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.

Common situations: 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).

Understand the failure class

Background: "API request failed": what wrapped HTTP errors from external APIs mean and how to find the real cause — this error's family across 29 libraries.

Related errors


AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11). Data as JSON: /api/errors/83be352f970c0df7. Report an issue: GitHub.