你好,我有这个问题。我将Laravelproject从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"
任何人都有一些技巧可以解决我的问题?
经过更多研究后,我发现它似乎在我构建消息的Controller中崩溃。
这是我的控制器:
<?php
namespace App\Mail;
use App\Models\Application;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;
class ApplicationCreated extends Mailable
{
use Queueable, SerializesModels;
public $isForSecretary;
public $isForHeadPhysician;
public $isForManagement;
public $application;
public $customMsg;
/**
* ApplicationCreated constructor.
* @param Application $application
* @param $isForSecretary
* @param $isForHeadPhysician
* @param null $customMsg
*/
public function __construct(Application $application, $isForSecretary, $isForHeadPhysician, $customMsg = null)
{
$this->application = $application;
$this->isForSecretary = $isForSecretary;
$this->isForHeadPhysician = $isForHeadPhysician;
$this->customMsg = $customMsg;
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
$applicant = $this->application->applicant;
return $this->view('application.responses.emails.application_created')
->subject('Reiseantrag: ' . $applicant->title . ' ' . $applicant->lastname)
->withApplication($this->application)
->withMail($this)
->with('customMsg', $this->customMsg);
}
}
在构建函数中,它似乎在return语句中的某个位置崩溃。