{"record":{"id":"4a72039943b14d14","repo":"flowable/flowable-engine","slug":"could-not-set-as-from-address-in-email","errorCode":null,"errorMessage":"Could not set  as from address in email","messagePattern":"Could not set  as from address in email","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":238,"sourceCode":"\n        // localPart@domainPart\n        return email.substring(0, atIndex) + '@' + IDN.toASCII(email.substring(atIndex + 1));\n\n    }\n\n    protected void setFrom(MimeMessage message, String from) {\n        String fromAddress;\n\n        if (from != null) {\n            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();","sourceCodeStart":220,"sourceCodeEnd":256,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-mail/src/main/java/org/flowable/mail/common/impl/jakarta/mail/JakartaMailFlowableMailClient.java#L220-L256","documentation":"setFrom applies the From address to the MimeMessage; if message.setFrom throws MessagingException after the address was constructed, the client wraps it in FlowableMailException naming the address: 'Could not set <address> as from address in email'. Note that a syntactically invalid From address would usually fail earlier with 'Invalid email' in createInternetAddress.","triggerScenarios":"Executing a send where the resolved From address (explicit request.from or the configured defaultFrom) causes MimeMessage.setFrom to throw — e.g. address already set illegally, or header issues during setFrom.","commonSituations":"Misconfigured default from address in mail server configuration; from address overridden per request with values from external systems; mail session/provider rejecting the identity configured.","solutions":["Check the wrapped MessagingException cause for the exact reason and correct the from address in the request or in the defaults configuration.","Verify the configured defaultFrom is a valid, permitted sender for your mail server (SPF/relay rules).","Explicitly set a known-good from address on the SendMailRequest instead of relying on defaults.","Confirm the JNDI/host-based mail session is configured for the domain you send from."],"exampleFix":"// before\ncfg.setDefaultFrom(\"\"\"do-not-reply\"\"\"); // not an address\n\n// after\ncfg.setDefaultFrom(\"do-not-reply@example.com\");","handlingStrategy":"validation","validationCode":"boolean isValidEmail(String s) {\n    if (s == null) return false;\n    try { new jakarta.mail.internet.InternetAddress(s.trim(), true).validate(); return true; }\n    catch (jakarta.mail.internet.AddressException e) { return false; }\n}\n// assert isValidEmail(cfg.getDefaultFrom()) at startup","typeGuard":null,"tryCatchPattern":"try { client.sendMail(request); } catch (FlowableMailException e) { if (e.getMessage().contains(\"as from address\")) { log.error(\"bad from address: \" + e.getMessage(), e.getCause()); } throw e; }","preventionTips":["Validate the defaultFrom mail configuration at application startup.","Ensure the from domain is authorized by your mail server (SPF/relay).","Prefer explicit from addresses in requests over implicit defaults."],"tags":["mail","from-address","jakarta-mail","configuration"],"backgroundTag":"invalid-config-value","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"}