{"record":{"id":"412284c8d8e489e9","repo":"ellite/Wallos","slug":"s-s","errorCode":null,"errorMessage":"%s: %s","messagePattern":"%s: %s","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"libs/PHPMailer/PHPMailer.php","lineNumber":1166,"sourceCode":"     * @param string $address The email address to send, resp. to reply to\n     * @param string $name\n     *\n     * @throws Exception\n     *\n     * @return bool true on success, false if address already used or invalid in some way\n     */\n    protected function addAnAddress($kind, $address, $name = '')\n    {\n        if (!in_array($kind, ['to', 'cc', 'bcc', 'Reply-To'])) {\n            $error_message = sprintf(\n                '%s: %s',\n                $this->lang('Invalid recipient kind'),\n                $kind\n            );\n            $this->setError($error_message);\n            $this->edebug($error_message);\n            if ($this->exceptions) {\n                throw new Exception($error_message);\n            }\n\n            return false;\n        }\n        if (!static::validateAddress($address)) {\n            $error_message = sprintf(\n                '%s (%s): %s',\n                $this->lang('invalid_address'),\n                $kind,\n                $address\n            );\n            $this->setError($error_message);\n            $this->edebug($error_message);\n            if ($this->exceptions) {\n                throw new Exception($error_message);\n            }\n\n            return false;","sourceCodeStart":1148,"sourceCodeEnd":1184,"githubUrl":"https://github.com/ellite/Wallos/blob/52820e87ca5a6e105fdbb7f1c0c681bc0cfee2fd/libs/PHPMailer/PHPMailer.php#L1148-L1184","documentation":"In addAnAddress, PHPMailer throws '%s: %s' when the $kind parameter is not one of the allowed recipient kinds (to, cc, bcc, Reply-To, From, ConfirmReadingTo). The message carries the localized 'Invalid recipient kind' text and the bad kind. Only thrown when $this->exceptions is true.","triggerScenarios":"Internal/indirect calls to addAnAddress (e.g., via call_user_func_array from preSend replaying RecipientsQueue/ReplyToQueue) receiving a corrupted or misspelled kind string; or user code calling the protected addAnAddress directly with an invalid first argument.","commonSituations":"Subclassing PHPMailer and calling addAnAddress('To', ...) with wrong case ('To' vs 'to'), version drift between PHPMailer 5.x ('to') and 6.x kinds, or queue params array whose [0] element was overwritten.","solutions":["Use the public API addAddress/addCC/addBCC/addReplyTo instead of calling addAnAddress directly","Use the exact kind strings PHPMailer expects ('to','cc','bcc','Reply-To','From','ConfirmReadingTo') if you must call it in a subclass","Inspect your RecipientsQueue entries if the error appears during send() — the queued params array was corrupted","Upgrade to a current PHPMailer 6.x release where kind handling is centralized"],"exampleFix":"// before\n$mail->addAnAddress('To', $email); // wrong case, invalid kind\n// after\n$mail->addAddress($email);","handlingStrategy":"type-guard","validationCode":"$allowed = ['to','cc','bcc','Reply-To','From','ConfirmReadingTo']; if (!in_array($kind, $allowed, true)) { throw new InvalidArgumentException(\"Bad kind: $kind\"); }","typeGuard":"function isValidRecipientKind(mixed $k): bool { return is_string($k) && in_array($k, ['to','cc','bcc','Reply-To','From','ConfirmReadingTo'], true); }","tryCatchPattern":"try { $mail->send(); } catch (PHPMailer\\PHPMailer\\Exception $e) { if (str_contains($e->getMessage(), 'Invalid recipient kind')) { /* inspect queued params */ } throw $e; }","preventionTips":["Use addAddress/addCC/addBCC/addReplyTo instead of addAnAddress","Never hand-build queue param arrays","Keep PHPMailer updated and avoid subclass internals","Use exact case-sensitive kind strings if you must call internals"],"tags":["php","phpmailer","email","invalid-argument"],"backgroundTag":"invalid-enum-value","analyzedSha":"52820e87ca5a6e105fdbb7f1c0c681bc0cfee2fd","analyzedAt":"2026-09-13T14:09:30.873Z","contentChangedAt":"2026-09-13T14:09:30.873Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}