【问题标题】:'Object of class Illuminate\Mail\Mailer could not be converted to string''Illuminate\Mail\Mailer 类的对象无法转换为字符串'
【发布时间】:2015-11-19 21:13:34
【问题描述】:

我正在尝试发送一封电子邮件确认以进行注册。我创建了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
  }

但是,我收到一个错误:

AppMailer.php 第 23 行中的 ErrorException:

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

【问题讨论】:

    标签: php email laravel laravel-5.1


    【解决方案1】:

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


    所以不要这样:

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

    使用这个:

    $this->mailer = $mailer;
    

    【讨论】:

      猜你喜欢
      • 2018-03-18
      • 2016-09-12
      • 1970-01-01
      • 2021-06-16
      • 2016-05-13
      • 2017-03-15
      • 2020-12-01
      • 2019-11-29
      • 2021-08-17
      相关资源
      最近更新 更多