{"record":{"id":"448fc1363f05eec3","repo":"Seldaek/monolog","slug":"the-content-type-can-not-contain-newline-character","errorCode":null,"errorMessage":"The content type can not contain newline characters to prevent email header injection","messagePattern":"The content type 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":152,"sourceCode":"\n    public function getContentType(): ?string\n    {\n        return $this->contentType;\n    }\n\n    public function getEncoding(): string\n    {\n        return $this->encoding;\n    }\n\n    /**\n     * @param  string $contentType The content type of the email - Defaults to text/plain. Use text/html for HTML messages.\n     * @return $this\n     */\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","sourceCodeStart":134,"sourceCodeEnd":170,"githubUrl":"https://github.com/Seldaek/monolog/blob/57eb1028342134e701e77c617565d51b6e5a2a53/src/Monolog/Handler/NativeMailerHandler.php#L134-L170","documentation":"Error \"The content type can not contain newline characters to prevent email header injection\" thrown in Seldaek/monolog.","triggerScenarios":"Thrown at src/Monolog/Handler/NativeMailerHandler.php:152 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"}