{"record":{"id":"4ffec55e5e11422f","repo":"quarkusio/quarkus","slug":"unable-to-send-an-email-an-email-address-is-inval","errorCode":null,"errorMessage":"Unable to send an email, an email address is invalid","messagePattern":"Unable to send an email, an email address is invalid","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"extensions/mailer/runtime/src/main/java/io/quarkus/mailer/runtime/MutinyMailerImpl.java","lineNumber":251,"sourceCode":"                new EmailAddress(email);\n            }\n            for (String email : cc) {\n                new EmailAddress(email);\n            }\n            for (String email : bcc) {\n                new EmailAddress(email);\n            }\n        } catch (IllegalArgumentException e) {\n            // One of the email addresses is invalid\n            if (logInvalidRecipients) {\n                // We are allowed to log the invalid email address\n                // The exception message contains the invalid email address.\n                LOGGER.warn(\"Unable to send an email\", e);\n                throw new IllegalArgumentException(\"Unable to send an email\", e);\n            } else {\n                // Do not print the invalid email address.\n                LOGGER.warn(\"Unable to send an email, an email address is invalid\");\n                throw new IllegalArgumentException(\"Unable to send an email, an email address is invalid\");\n            }\n        }\n    }\n\n    private MultiMap toMultimap(Map<String, List<String>> headers) {\n        MultiMap mm = MultiMap.caseInsensitiveMultiMap();\n        headers.forEach(mm::add);\n        return mm;\n    }\n\n    private Uni<MailAttachment> toMailAttachment(Attachment attachment) {\n        MailAttachment attach = MailAttachment.create();\n        attach.setName(attachment.getName());\n        attach.setContentId(attachment.getContentId());\n        attach.setDescription(attachment.getDescription());\n        attach.setDisposition(attachment.getDisposition());\n        attach.setContentType(attachment.getContentType());\n","sourceCodeStart":233,"sourceCodeEnd":269,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/mailer/runtime/src/main/java/io/quarkus/mailer/runtime/MutinyMailerImpl.java#L233-L269","documentation":"Identical to the previous case but thrown when logInvalidRecipients is false: the library deliberately hides the invalid address from the exception and logs only \"an email address is invalid\", since exception messages could leak recipient data. The original parsing exception is swallowed (only a sanitized warning is logged).","triggerScenarios":"Sending a mail with any malformed address while quarkus.mailer.log-invalid-recipients is false (the default), so validate() throws the sanitized IllegalArgumentException.","commonSituations":"Production hardening hides which address failed, making debugging hard; batch sends where one bad address aborts the send; data migrations importing addresses with trailing commas or brackets.","solutions":["Temporarily set quarkus.mailer.log-invalid-recipients=true in dev/test to see the offending address in the log and the exception cause.","Pre-validate addresses in your own code so the failure points at the exact input before calling send().","Sanitize inputs: trim, strip surrounding brackets/commas, verify domain presence.","Add structured logging around your send call capturing the recipient list you attempted."],"exampleFix":"// before (which address failed is hidden)\nmailer.send(Mail.withText(rawRecipient, subject, body));\n\n// after (validate first, log the rejected value yourself)\nif (!EMAIL.matcher(rawRecipient.trim()).matches()) {\n    LOG.warnf(\"Rejecting invalid recipient: %s\", rawRecipient);\n    return;\n}\nmailer.send(Mail.withText(rawRecipient.trim(), subject, body));","handlingStrategy":"try-catch","validationCode":"List<String> invalid = Stream.of(to, cc, bcc, from)\n        .filter(Objects::nonNull)\n        .filter(a -> !isValidEmail(a))\n        .toList();\nif (!invalid.isEmpty()) {\n    LOG.warnf(\"Rejecting send; invalid addresses: %s\", invalid);\n    return;\n}","typeGuard":"static boolean isValidEmail(String address) {\n    return address != null && !address.isBlank() && EMAIL.matcher(address.trim()).matches();\n}","tryCatchPattern":"try {\n    mailer.send(mail).await().indefinitely();\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().equals(\"Unable to send an email, an email address is invalid\")) {\n        LOG.warn(\"An address failed validation; enable quarkus.mailer.log-invalid-recipients locally to see it\");\n    }\n    throw e;\n}","preventionTips":["Pre-validate addresses yourself since production hides the offending value","Set quarkus.mailer.log-invalid-recipients=true only in dev/test","Log your attempted recipient list (after redaction) before calling send()","Sanitize imported data: strip commas, brackets and whitespace from addresses"],"tags":["quarkus","mailer","email-validation","invalid-address","illegal-argument"],"backgroundTag":"invalid-email-address","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}