【发布时间】:2020-03-31 12:00:24
【问题描述】:
你好,我有这个问题。 我将 Laravel 项目从 5.4 更新到 5.7。 在我无法再发送邮件之后。我确保我有正确的 Swiftmailer 包和所有版本。 经过一番研究,我发现我的应用程序在函数 addContent() 中的 Mailer.php 处崩溃。
protected function addContent($message, $view, $plain, $raw, $data)
{
if (isset($view)) {
/* At this Point my application is crashing.
$message->setBody($this->renderView($view, $data), 'text/html');
*/
}
if (isset($plain)) {
$method = isset($view) ? 'addPart' : 'setBody';
$message->$method($this->renderView($plain, $data), 'text/plain');
}
if (isset($raw)) {
$method = (isset($view) || isset($plain)) ? 'addPart' : 'setBody';
$message->$method($raw, 'text/plain');
}
}
我的 php 错误日志显示此错误消息:
"PHP Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 32768 bytes) in C:\\webroot\\projectname\\vendor\\symfony\\debug\\Exception\\FatalErrorException.php on line 1, referer: http://localhost/intranet/projectname/other-applications/create"
谁有一些技巧可以解决我的问题?
【问题讨论】:
-
首先要弄清楚问题实际上是出在 Swift Mailer 上,还是出在您尝试在那里渲染的模板上 - 如果您在那个地方只使用
$foo = $this->renderView($view, $data);,它还会崩溃吗? -
@Cbroe 如果我尝试这样做,它仍然会崩溃
if (isset($view)) { $foo = $this->renderView($view, $data); echo "HEre"; dd($view); }
标签: php laravel swiftmailer