{"record":{"id":"f5541b5cf1fee8cd","repo":"flowable/flowable-engine","slug":"no-recipient-could-be-found-for-sending-email-for","errorCode":null,"errorMessage":"No recipient could be found for sending email for \" + variableContainer","messagePattern":"No recipient could be found for sending email for \" \\+ variableContainer","errorType":"exception","errorClass":"FlowableException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/mail/BaseMailActivityDelegate.java","lineNumber":109,"sourceCode":"\n    protected MailMessage createMessage(V variableContainer) {\n\n        String headersStr = getStringFromField(headers, variableContainer);\n        Collection<String> toList = parseRecipients(to, variableContainer);\n        String fromStr = getStringFromField(from, variableContainer);\n        Collection<String> ccList = parseRecipients(cc, variableContainer);\n        Collection<String> bccList = parseRecipients(bcc, variableContainer);\n        String subjectStr = getStringFromField(subject, variableContainer);\n        String textStr = textVar == null ?\n                getStringFromField(text, variableContainer) :\n                getStringFromField(getExpression(variableContainer, textVar), variableContainer);\n        String htmlStr = htmlVar == null ?\n                getStringFromField(html, variableContainer) :\n                getStringFromField(getExpression(variableContainer, htmlVar), variableContainer);\n        String charSetStr = getStringFromField(charset, variableContainer);\n\n        if (toList.isEmpty() && ccList.isEmpty() && bccList.isEmpty()) {\n            throw new FlowableException(\"No recipient could be found for sending email for \" + variableContainer);\n        }\n\n        if (htmlStr == null && textStr == null) {\n            throw new FlowableIllegalArgumentException(\"'html' or 'text' is required to be defined when using the mail activity\");\n        }\n\n        MailMessage message = new MailMessage();\n\n        addHeader(message, headersStr);\n        message.setTo(toList);\n        message.setFrom(fromStr);\n        message.setCc(ccList);\n        message.setBcc(bccList);\n        message.setSubject(subjectStr);\n        message.setPlainContent(textStr);\n        message.setHtmlContent(htmlStr);\n        if (charSetStr != null) {\n            message.setCharset(Charset.forName(charSetStr));","sourceCodeStart":91,"sourceCodeEnd":127,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/mail/BaseMailActivityDelegate.java#L91-L127","documentation":"BaseMailActivityDelegate.createMessage builds the mail message from the mail activity's field injections (to, cc, bcc expressions). If after evaluating all recipient expressions the to, cc, and bcc lists are all empty, it throws FlowableException because an email without any recipient cannot be sent.","triggerScenarios":"A mail task/service with no 'to' field defined; 'to' configured via an expression/variable that evaluates to null or empty string at runtime (missing process variable, empty collection in toVar).","commonSituations":"BPMN mail task relying on a process variable for recipients that was never set; variables containing empty strings or empty lists; copy-pasted mail task template missing recipient fields.","solutions":["Set the 'to' field (or toVar/to expression) on the mail activity with a valid address or non-empty variable","Verify at runtime that the recipient process variables are populated before the mail task executes","If recipients are optional by design, guard the mail task with a condition or default recipient"],"exampleFix":"<!-- before -->\n<flowable:field name=\"to\" expression=\"${recipientEmail}\"/>\n<!-- after: ensure variable exists or provide fallback -->\n<flowable:field name=\"to\" expression=\"${recipientEmail != null ? recipientEmail : 'default@example.com'}\"/>","handlingStrategy":"validation","validationCode":"String to = (String) variableContainer.getVariable(\"recipientEmail\");\nif (to == null || to.isBlank()) throw new IllegalStateException(\"Mail task requires a non-empty recipient before reaching mail activity\");","typeGuard":null,"tryCatchPattern":"try { createMessage(...); } catch (FlowableException e) { if (e.getMessage().startsWith(\"No recipient could be found\")) { logger.error(\"Mail task missing recipients: {}\", variableContainer.getVariables()); } throw e; }","preventionTips":["Always define at least the 'to' field on mail tasks","Validate recipient variables early in the process, before the mail task","Use a default/fallback recipient expression for optional recipient flows"],"tags":["email","mail-task","validation","recipients"],"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"}