'Object of class Illuminate\Mail\Mailer could not be converted to string'

'Object of class Illuminate\Mail\Mailer could not be converted to string'

我正在尝试发送电子邮件确认注册。我创建了 app>Mailers>AppMailer.

class AppMailer {

  protected $mailer;

  protected $from = 'admin@example.com';

  protected $to;

  protected $view;

  protected $data = [];


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

但是,我收到一个错误:

ErrorException in AppMailer.php line 23:

Object of class Illuminate\Mail\Mailer could not be converted to string

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


所以不是这个:

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

使用这个:

$this->mailer = $mailer;