{"record":{"id":"837dd591fda463a1","repo":"flowable/flowable-engine","slug":"invalid-email","errorCode":null,"errorMessage":"Invalid email","messagePattern":"Invalid 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":211,"sourceCode":"        }\n        if (!newRecipients.isEmpty()) {\n            for (String t : newRecipients) {\n                try {\n                    message.addRecipient(recipientType, createInternetAddress(t));\n                } catch (MessagingException e) {\n                    throw new FlowableMailException(\"Could not add \" + t + \" as \" + recipientType + \" recipient\", e);\n                }\n            }\n        }\n    }\n\n    protected InternetAddress createInternetAddress(String email) {\n        try {\n            InternetAddress address = new InternetAddress(toASCIIEmail(email));\n            address.validate();\n            return address;\n        } catch (AddressException e) {\n            throw new FlowableMailException(\"Invalid email\", e);\n        }\n    }\n\n    protected String toASCIIEmail(String email) {\n        int atIndex = email.indexOf('@');\n        if (atIndex < 0) {\n            return email;\n        }\n\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) {","sourceCodeStart":193,"sourceCodeEnd":229,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-mail/src/main/java/org/flowable/mail/common/impl/jakarta/mail/JakartaMailFlowableMailClient.java#L193-L229","documentation":"createInternetAddress converts the given string to an ASCII email, constructs a jakarta.mail InternetAddress and calls validate(). If validation raises AddressException, the client wraps it in FlowableMailException('Invalid email'). It means the supplied string is not a syntactically valid email address.","triggerScenarios":"Calling setFrom or any add*Recipient with a string that fails InternetAddress validation — missing '@', illegal characters, malformed domain, or characters that cannot be converted to ASCII by toASCIIEmail.","commonSituations":"Free-text user input used as email address; 'Name <email>' or comma-separated multi-address strings passed to single-address APIs; internationalized addresses where IDN conversion fails; trailing whitespace or newlines from CSV import.","solutions":["Fix the offending address string; validate with a regex or InternetAddress(email).validate() before sending.","Trim whitespace and strip display-name decorations, passing only the bare address.","If sending to multiple addresses, split on commas and add each separately.","For internationalized addresses, ensure IDN/punycode conversion of the domain is performed before calling the client."],"exampleFix":"// before\nrequest.setFrom(\"Flowable Bot <no-reply@example.com>\");\n\n// after\nrequest.setFrom(\"no-reply@example.com\"); // bare, validated address","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}","typeGuard":"boolean isPlainAddress(String s) { return s != null && s.matches(\"^[^@\\\\s]+@[^@\\\\s]+\\\\.[^@\\\\s]+$\"); }","tryCatchPattern":"try { request.setFrom(from); } catch (FlowableMailException e) { if (e.getMessage().equals(\"Invalid email\")) { throw new InvalidMailAddressException(from); } throw e; }","preventionTips":["Strip display names and only pass bare addresses to setFrom/addRecipient.","Validate emails at data-entry time, not send time.","Handle internationalized domains via IDN conversion before sending."],"tags":["mail","email-validation","jakarta-mail","address"],"backgroundTag":"invalid-argument-format","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"}