{"record":{"id":"7bd99545fe55ed58","repo":"Seldaek/monolog","slug":"could-not-resolve-message-as-instance-of-email-or","errorCode":null,"errorMessage":"Could not resolve message as instance of Email or a callable returning it","messagePattern":"Could not resolve message as instance of Email or a callable returning it","errorType":"exception","errorClass":"InvalidArgumentException","httpStatus":null,"severity":"error","filePath":"src/Monolog/Handler/SymfonyMailerHandler.php","lineNumber":85,"sourceCode":"    /**\n     * Creates instance of Email to be sent\n     *\n     * @param string      $content formatted email body to be sent\n     * @param LogRecord[] $records Log records that formed the content\n     */\n    protected function buildMessage(string $content, array $records): Email\n    {\n        $message = null;\n        if ($this->emailTemplate instanceof Email) {\n            $message = clone $this->emailTemplate;\n        } elseif (\\is_callable($this->emailTemplate)) {\n            $message = ($this->emailTemplate)($content, $records);\n        }\n\n        if (!$message instanceof Email) {\n            $record = reset($records);\n\n            throw new \\InvalidArgumentException('Could not resolve message as instance of Email or a callable returning it' . ($record instanceof LogRecord ? Utils::getRecordMessageForException($record) : ''));\n        }\n\n        if (\\count($records) > 0) {\n            $subjectFormatter = $this->getSubjectFormatter($message->getSubject());\n            $message->subject($subjectFormatter->format($this->getHighestRecord($records)));\n        }\n\n        if ($this->isHtmlBody($content)) {\n            if (null !== ($charset = $message->getHtmlCharset())) {\n                $message->html($content, $charset);\n            } else {\n                $message->html($content);\n            }\n        } else {\n            if (null !== ($charset = $message->getTextCharset())) {\n                $message->text($content, $charset);\n            } else {\n                $message->text($content);","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/Seldaek/monolog/blob/57eb1028342134e701e77c617565d51b6e5a2a53/src/Monolog/Handler/SymfonyMailerHandler.php#L67-L103","documentation":"Error \"Could not resolve message as instance of Email or a callable returning it\" thrown in Seldaek/monolog.","triggerScenarios":"Thrown at src/Monolog/Handler/SymfonyMailerHandler.php:85 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"}