{"record":{"id":"846784e2d81aba44","repo":"ellite/Wallos","slug":"invalid-address-s-s","errorCode":null,"errorMessage":"Invalid address (%s): %s","messagePattern":"Invalid address \\((.+?)\\): (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"libs/PHPMailer/PHPMailer.php","lineNumber":1593,"sourceCode":"                    $this->{$address_kind} = '';\n                    continue;\n                }\n                $this->{$address_kind} = trim($this->{$address_kind});\n                if (empty($this->{$address_kind})) {\n                    continue;\n                }\n                $this->{$address_kind} = $this->punyencodeAddress($this->{$address_kind});\n                if (!static::validateAddress($this->{$address_kind})) {\n                    $error_message = sprintf(\n                        '%s (%s): %s',\n                        $this->lang('invalid_address'),\n                        $address_kind,\n                        $this->{$address_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            }\n\n            //Set whether the message is multipart/alternative\n            if ($this->alternativeExists()) {\n                $this->ContentType = static::CONTENT_TYPE_MULTIPART_ALTERNATIVE;\n            }\n\n            $this->setMessageType();\n            //Refuse to send an empty message unless we are specifically allowing it\n            if (!$this->AllowEmpty && empty($this->Body)) {\n                throw new Exception($this->lang('empty_message'), self::STOP_CRITICAL);\n            }\n\n            //Trim subject consistently","sourceCodeStart":1575,"sourceCodeEnd":1611,"githubUrl":"https://github.com/ellite/Wallos/blob/52820e87ca5a6e105fdbb7f1c0c681bc0cfee2fd/libs/PHPMailer/PHPMailer.php#L1575-L1611","documentation":"preSend() validates the From, Sender, and ConfirmReadingTo properties after recipients are processed and throws 'Invalid address (%s): %s' (kind and value) when any of them fails validateAddress(). Thrown only with exceptions enabled; otherwise the error is recorded and preSend returns false, aborting send().","triggerScenarios":"setFrom()/setSender()/ConfirmReadingTo set to an address failing validation; properties set directly ($mail->From = 'bad') bypassing setFrom()'s checks; addresses corrupted by later code before send().","commonSituations":"Setting $mail->From directly from config without validation, Sender path ('/usr/sbin/sendmail'-style values or invalid return-path) misconfigured, confirm-reading-to (read receipt) address copied from unvalidated user input.","solutions":["Use setFrom()/Sender setter APIs rather than assigning ->From/->Sender properties directly","Validate each with PHPMailer::validateAddress() before assignment","Remove or correctly set ConfirmReadingTo if read receipts are not needed","Catch the exception around send() and log which address kind failed (the message includes the kind)"],"exampleFix":"// before\n$mail->From = $_GET['from']; // bypasses validation, fails in preSend\n// after\n$from = $_GET['from'];\nif (PHPMailer::validateAddress($from)) {\n    $mail->setFrom($from);\n} else {\n    throw new InvalidArgumentException('Invalid From address');\n}","handlingStrategy":"validation","validationCode":"foreach (['From'=>$from,'Sender'=>$sender,'ConfirmReadingTo'=>$confirm] as $k=>$a) { if ($a !== '' && !PHPMailer::validateAddress($a)) { throw new InvalidArgumentException(\"Invalid $k: $a\"); } }","typeGuard":null,"tryCatchPattern":"try { $mail->send(); } catch (PHPMailer\\PHPMailer\\Exception $e) { // message contains the address kind that failed $log->error($e->getMessage()); throw $e; }","preventionTips":["Set From/Sender/ConfirmReadingTo only through official setters","Validate config-sourced addresses at boot time","Drop ConfirmReadingTo unless read receipts are required","Never assign address properties directly from untrusted input"],"tags":["php","phpmailer","email","address-validation"],"backgroundTag":"invalid-argument-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"}