试图在mailgun中获取非对象的属性“消息”

时间:2018-04-28 09:13:22

标签: php laravel mailgun

我使用的是mailgun:

.env代码:

MAIL_DRIVER=mailgun
MAIL_HOST=smtp.mailgun.org
MAIL_PORT=2525
MAIL_USERNAME=postmaster@sandbox******.mailgun.org
MAIL_PASSWORD=9******
MAIL_ENCRYPTION=null
MAILGUN_DOMAIN=sandbox********.mailgun.org
MAILGUN_SECRET=key-*********
MAIL_FROM_ADDRESS: hello@yourdomain.com
MAIL_FROM_NAME: reza

发送邮件代码:

$data = array(
            'title' => $request->input('title'),
            'date' => $time,
            'time' => $request->input('start'),
            'address' => $request->input('title'),
            'end' => $date->modify("+{$duration} minutes"),
        );


Mailgun::send('emails.Meeting', $data, function ($message) {
            $message->to('foo@example.com', 'John Doe')->subject('Welcome!');
        });

调用此函数时,我收到此错误:

  

尝试获取非对象的属性“消息”

为什么?

1 个答案:

答案 0 :(得分:0)

我认为唯一的错误是

$message->to('foo@example.com', 'John Doe')->subject('Welcome!');

试试这个

       $data = array(
            'title' => $request->input('title'),
            'date' => $time,
            'time' => $request->input('start'),
            'address' => $request->input('title'),
            'end' => $date->modify("+{$duration} minutes"),
        );


       Mailgun::send('emails.Meeting', $data, function ($message) {
            $message->to('foo@example.com', 'John Doe');
            $message->subject('Welcome!');
        });

如果上述代码不起作用,您的电子邮件怎么样。会议模板看起来像?