Php 如何修复Laravel Swiftmailer中耗尽的允许内存大小?
你好,我有这个问题。 我将我的Laravelproject从5.4更新到5.7。 之后我再也不能发邮件了。我确保我有正确的Swiftmailer软件包和所有版本。 经过一些研究,我发现我的应用程序在函数addContent()的Mailer.php上崩溃了 我的php错误日志显示以下错误消息:Php 如何修复Laravel Swiftmailer中耗尽的允许内存大小?,php,laravel,swiftmailer,Php,Laravel,Swiftmailer,你好,我有这个问题。 我将我的Laravelproject从5.4更新到5.7。 之后我再也不能发邮件了。我确保我有正确的Swiftmailer软件包和所有版本。 经过一些研究,我发现我的应用程序在函数addContent()的Mailer.php上崩溃了 我的php错误日志显示以下错误消息: "PHP Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 32768 bytes) in
"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"
任何人都有一些我如何解决问题的建议吗?经过进一步的研究,我发现它似乎在我构建消息的控制器中崩溃了 这是我的控制器:
<?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);
}
}
首先要弄清楚问题究竟是出在Swift-Mailer上,还是出在您试图呈现的模板上-如果您只是$foo=$this->renderView($view,$data)代码>在那个地方,它仍然崩溃吗?@Cbroe如果我尝试这个方法,它仍然崩溃if(isset($view)){$foo=$this->renderView($view,$data);echo“HEre”;dd($view);}
<?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);
}
}