'类 Illuminate\Mail\Mailer 的对象无法转换为字符串'

问题描述 投票:0回答:2

我正在尝试发送电子邮件确认注册。我已经创建了

app>Mailers>AppMailer

class AppMailer {

  protected $mailer;

  protected $from = '[email protected]';

  protected $to;

  protected $view;

  protected $data = [];


  public function __construct(Mailer $mailer)
  {
    $this->$mailer = $mailer;   // Line 23
  }

但是,我收到错误:

AppMailer.php 第 23 行中的ErrorException:

类 Illuminate\Mail\Mailer 的对象无法转换为字符串

php email laravel laravel-5.1
2个回答
4
投票

设置

$this->mailer
,而不是
$this->$mailer


所以代替这个:

$this->$mailer = $mailer;
    // ^

使用这个:

$this->mailer = $mailer;

0
投票
return $this->subject('Your Password Expires Soon')->$this->view('Email.Password-Policy.PasswordPolicyMail');

更改为

return $this->subject('Your Password Expires Soon')->view('Email.Password-Policy.PasswordPolicyMail');
© www.soinside.com 2019 - 2024. All rights reserved.