{"record":{"id":"f3e1319d22b2ceba","repo":"Seldaek/monolog","slug":"the-encoding-can-not-contain-newline-characters-to","errorCode":null,"errorMessage":"The encoding can not contain newline characters to prevent email header injection","messagePattern":"The encoding can not contain newline characters to prevent email header injection","errorType":"exception","errorClass":"InvalidArgumentException","httpStatus":null,"severity":"error","filePath":"src/Monolog/Handler/NativeMailerHandler.php","lineNumber":166,"sourceCode":"     */\n    public function setContentType(string $contentType): self\n    {\n        if (strpos($contentType, \"\\n\") !== false || strpos($contentType, \"\\r\") !== false) {\n            throw new \\InvalidArgumentException('The content type can not contain newline characters to prevent email header injection');\n        }\n\n        $this->contentType = $contentType;\n\n        return $this;\n    }\n\n    /**\n     * @return $this\n     */\n    public function setEncoding(string $encoding): self\n    {\n        if (strpos($encoding, \"\\n\") !== false || strpos($encoding, \"\\r\") !== false) {\n            throw new \\InvalidArgumentException('The encoding can not contain newline characters to prevent email header injection');\n        }\n\n        $this->encoding = $encoding;\n\n        return $this;\n    }\n\n\n    protected function mail(string $to, string $subject, string $content, string $headers, string $parameters): void\n    {\n        mail($to, $subject, $content, $headers, $parameters);\n    }\n}\n","sourceCodeStart":148,"sourceCodeEnd":180,"githubUrl":"https://github.com/Seldaek/monolog/blob/57eb1028342134e701e77c617565d51b6e5a2a53/src/Monolog/Handler/NativeMailerHandler.php#L148-L180","documentation":"Error \"The encoding can not contain newline characters to prevent email header injection\" thrown in Seldaek/monolog.","triggerScenarios":"Thrown at src/Monolog/Handler/NativeMailerHandler.php:166 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"57eb1028342134e701e77c617565d51b6e5a2a53","analyzedAt":"2026-08-17T02:36:30.259Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}