使用Laravel和SendGrind遇到麻烦

时间:2019-05-25 19:11:11

标签: laravel-5 sendgrid

我正在尝试在laravel中使用SendGrid在我的应用程序上发送电子邮件。 但是出现此错误:

  

stream_socket_enable_crypto():对等证书CN = *.smtp.sendgrid.net' did not match expected CN= smtp.sendgrid.com'

我遵循了所有文档,所有内容都相同,但是不起作用。

TestMail文件

    <?php

namespace App\Mail;

use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;

class TestEmail extends Mailable
{
    use Queueable, SerializesModels;

public $data;

public function __construct($data)
{
    $this->data = $data;
}

public function build()
{
    $address = 'gabriel.jg04@gmail.com';
    $subject = 'Test!';
    $name = 'João Gabriel';

    return $this->view('emails.test')
                ->from($address, $name)
                ->cc($address, $name)
                ->bcc($address, $name)
                ->replyTo($address, $name)
                ->subject($subject)
                ->with([ 'message' => $this->data['message'] ]);
}

}

我的环境文件:

MAIL_DRIVER=smtp
MAIL_HOST=smtp.sendgrid.net
MAIL_PORT=587
MAIL_USERNAME="João Gabriel"
MAIL_PASSWORD=joaobiel04
MAIL_ENCRYPTION=tls
MAIL_FROM_NAME="João Gabriel"
MAIL_FROM_ADDRESS=gabriel_fla04@hotmail.com

我的路线:

Route::get('/testmail', function () {
    $data = ['message' => 'Test!'];

    Mail::to('gabriel_fla04@hotmail.com')->send(new TestEmail($data));
    return back();
})->name('testmail');

0 个答案:

没有答案