{"record":{"id":"d3721ba51bbc59d4","repo":"ellite/Wallos","slug":"this-lang-empty-message","errorCode":null,"errorMessage":"$this->lang('empty_message')","messagePattern":"\\$this->lang\\('empty_message'\\)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"libs/PHPMailer/PHPMailer.php","lineNumber":3040,"sourceCode":"                $body .= static::$LE;\n                $body .= $this->attachAll('inline', $this->boundary[3]);\n                $body .= static::$LE;\n                $body .= $this->endBoundary($this->boundary[2]);\n                $body .= static::$LE;\n                $body .= $this->attachAll('attachment', $this->boundary[1]);\n                break;\n            default:\n                //Catch case 'plain' and case '', applies to simple `text/plain` and `text/html` body content types\n                //Reset the `Encoding` property in case we changed it for line length reasons\n                $this->Encoding = $bodyEncoding;\n                $body .= $this->encodeString($this->Body, $this->Encoding);\n                break;\n        }\n\n        if ($this->isError()) {\n            $body = '';\n            if ($this->exceptions) {\n                throw new Exception($this->lang('empty_message'), self::STOP_CRITICAL);\n            }\n        } elseif ($this->sign_key_file) {\n            try {\n                if (!defined('PKCS7_TEXT')) {\n                    throw new Exception($this->lang('extension_missing') . 'openssl');\n                }\n\n                $file = tempnam(sys_get_temp_dir(), 'srcsign');\n                $signed = tempnam(sys_get_temp_dir(), 'mailsign');\n                file_put_contents($file, $body);\n\n                //Workaround for PHP bug https://bugs.php.net/bug.php?id=69197\n                if (empty($this->sign_extracerts_file)) {\n                    $sign = @openssl_pkcs7_sign(\n                        $file,\n                        $signed,\n                        'file://' . realpath($this->sign_cert_file),\n                        ['file://' . realpath($this->sign_key_file), $this->sign_key_pass],","sourceCodeStart":3022,"sourceCodeEnd":3058,"githubUrl":"https://github.com/ellite/Wallos/blob/52820e87ca5a6e105fdbb7f1c0c681bc0cfee2fd/libs/PHPMailer/PHPMailer.php#L3022-L3058","documentation":"PHPMailer throws 'empty_message' (STOP_CRITICAL) in createBody() when the composed message body ends up empty and the instance has exceptions enabled. It signals that send() cannot proceed because there is no HTML or plain-text body to transmit.","triggerScenarios":"Calling send()/preSend() when $this->Body and $this->AltBody are both empty (e.g. msgHTML() was given an empty string or a body that rendered to nothing), or a body-building branch produced nothing.","commonSituations":"Rendering a Twig/Smarty template that outputs only whitespace, calling msgHTML(''), forgetting to set Body/AltBody, or clearing the body after an earlier send() call.","solutions":["Set $mail->Body (and optionally $mail->AltBody) to a non-empty string before send()","If using msgHTML(), verify the source HTML is non-empty after rendering","Set $mail->isHTML(true) with a real body instead of relying on defaults"],"exampleFix":"// before\n$mail->msgHTML($template->render([])); // renders empty\n// after\n$html = $template->render(['user' => $user]);\nif (trim($html) === '') { throw new RuntimeException('Template rendered empty body'); }\n$mail->msgHTML($html);","handlingStrategy":"validation","validationCode":"if (trim($mail->Body) === '' && trim($mail->AltBody) === '') { throw new LogicException('PHPMailer body is empty; set Body/AltBody before send()'); }","typeGuard":"function hasNonEmptyString($v): bool { return is_string($v) && trim($v) !== ''; }","tryCatchPattern":"try { $mail->send(); } catch (PHPMailer\\PHPMailer\\Exception $e) { if (str_contains($e->getMessage(), 'empty_message') || str_contains($e->getMessage(), 'Message body empty')) { /* fix body */ } throw $e; }","preventionTips":["Always set Body or call msgHTML() with verified non-empty HTML","Assert the template render output is non-empty before assigning it","Add a pre-send invariant check for Body/AltBody in your mailer wrapper"],"tags":["phpmailer","email","empty-body"],"backgroundTag":"empty-required-field","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"}