Seldaek/monolog · error · InvalidArgumentException
Could not resolve message as instance of Email or a callable
Error message
Could not resolve message as instance of Email or a callable returning it
What it means
Error "Could not resolve message as instance of Email or a callable returning it" thrown in Seldaek/monolog.
Source
Thrown at src/Monolog/Handler/SymfonyMailerHandler.php:85
/**
* Creates instance of Email to be sent
*
* @param string $content formatted email body to be sent
* @param LogRecord[] $records Log records that formed the content
*/
protected function buildMessage(string $content, array $records): Email
{
$message = null;
if ($this->emailTemplate instanceof Email) {
$message = clone $this->emailTemplate;
} elseif (\is_callable($this->emailTemplate)) {
$message = ($this->emailTemplate)($content, $records);
}
if (!$message instanceof Email) {
$record = reset($records);
throw new \InvalidArgumentException('Could not resolve message as instance of Email or a callable returning it' . ($record instanceof LogRecord ? Utils::getRecordMessageForException($record) : ''));
}
if (\count($records) > 0) {
$subjectFormatter = $this->getSubjectFormatter($message->getSubject());
$message->subject($subjectFormatter->format($this->getHighestRecord($records)));
}
if ($this->isHtmlBody($content)) {
if (null !== ($charset = $message->getHtmlCharset())) {
$message->html($content, $charset);
} else {
$message->html($content);
}
} else {
if (null !== ($charset = $message->getTextCharset())) {
$message->text($content, $charset);
} else {
$message->text($content);View on GitHub (pinned to 57eb102834)
When it happens
Trigger: Thrown at src/Monolog/Handler/SymfonyMailerHandler.php:85 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of Seldaek/monolog@57eb102834 (2026-08-17).
Data as JSON: /api/errors/7bd99545fe55ed58.
Report an issue: GitHub.