{"record":{"id":"5ba360228c0b97b8","repo":"flowable/flowable-engine","slug":"html-or-text-is-required-to-be-defined-when-se","errorCode":null,"errorMessage":"'html' or 'text' is required to be defined when sending an email","messagePattern":"'html' or 'text' is required to be defined when sending an email","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-mail/src/main/java/org/flowable/mail/common/impl/jakarta/mail/JakartaMailFlowableMailClient.java","lineNumber":258,"sourceCode":"    }\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 {\n            try {\n                mimeMessage.setContent(createMultiPartContent(text, html, charset, attachments));\n            } catch (MessagingException e) {\n                throw new FlowableMailException(\"Failed to create multi part email\", e);\n            }\n        }\n    }\n\n    protected MimeMultipart createMultiPartContent(String text, String html, String charset, Collection<DataSource> attachments) throws MessagingException {\n        boolean attachmentsExists = attachments != null && !attachments.isEmpty();","sourceCodeStart":240,"sourceCodeEnd":276,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-mail/src/main/java/org/flowable/mail/common/impl/jakarta/mail/JakartaMailFlowableMailClient.java#L240-L276","documentation":"setContent() requires an email body: when both html and plain text content of the MailMessage are null, it throws FlowableIllegalArgumentException. An email with attachments but no body is also rejected. This is a validation guard ensuring the MIME message always has content.","triggerScenarios":"Sending via the mail activity/send API with a MailMessage where setPlainContent(null)/no text and setHtmlContent(null)/no html were set — even when attachments are present.","commonSituations":"BPMN mail task XML omitting the html/text fields; building MailMessage programmatically and forgetting to set body; template rendering producing null/empty so content never gets assigned; setting only attachments.","solutions":["Set the 'html' field (or setHtmlContent) on the MailMessage / mail task configuration","Or set the 'text' field (or setPlainContent) for a plain-text email","In BPMN mail tasks, add <flowable:field name=\"html\" ...> or name=\"text\" to the task definition","If the body is intentionally empty, send a minimal body like a space or placeholder"],"exampleFix":"// before (BPMN mail task)\n<flowable:field name=\"to\" expression=\"${to}\" />\n// after\n<flowable:field name=\"to\" expression=\"${to}\" />\n<flowable:field name=\"html\">\n  <flowable:expression>${content}</flowable:expression>\n</flowable:field>","handlingStrategy":"validation","validationCode":"if (mailMessage.getPlainContent() == null && mailMessage.getHtmlContent() == null) {\n    throw new IllegalArgumentException(\"Email body required: set text or html before sending\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    mailClient.send(mailMessage);\n} catch (FlowableIllegalArgumentException e) {\n    if (e.getMessage().contains(\"'html' or 'text' is required\")) {\n        log.error(\"Mail task is missing its body content\");\n    }\n}","preventionTips":["Always set html or text on MailMessage before send, even when attachments exist","Validate mail task XML fields (text/html) in CI with a BPMN lint","Check template rendering output is non-null before assigning to the mail body"],"tags":["mail","validation","missing-body","mail-task"],"backgroundTag":"missing-required-argument","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}