"stream_socket_enable_crypto():对等证书CN ='gains.nanosupercloud.com'与预期的CN ='smtp.sendgrid.net'不匹配.在共享主机中

问题描述:

我在laravel中从事邮件工作.我正在按照配置进行操作.

I'm working in mail in laravel. I've following configuration.

MAIL_DRIVER=smtp
MAIL_HOST=smtp.sendgrid.net
MAIL_PORT=587
MAIL_USERNAME=********
MAIL_PASSWORD=########
MAIL_ENCRYPTION=tls

我已经尝试过了,但是没有用

I've already tried this one but not working

stream_socket_enable_crypto():对等体证书CN =`cs723.mojohost.com'与预期的CN =`smtp.sendgrid.net'不匹配

还有更多类似的问题,但我仍然没有解决方案.我出现以下错误:

And many more similar question but still i don't get the solution. I've following error:

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

ErrorException (E_WARNING) stream_socket_enable_crypto(): Peer certificate CN=gains.nanosupercloud.com' did not match expected CN=smtp.sendgrid.net'

我不知道我在做什么错.这是用于发送电子邮件的代码.

I don't know what i'm doing wrong. Here is the code used for email sending.

public function toMail($notifiable)
{
    return (new MailMessage)
                ->from(\Config::get('values.app_email'),\Config::get('values.app_name'))
                ->subject('Successfully approved your Company')
                ->greeting(sprintf('Hello %s', $this->user->name))
                ->line('Your company has been approved successfully. Now, it will be visible to our website');
}

任何建议都值得赞赏.

注意:一切都可以在本地服务器上正常运行(ubantu 16.04)

我给出的答案可能看起来很有趣,但是在实时服务器中发送邮件时我遇到了相同的错误

The answer i am giving may look funny but i have same error while sending mail in the live server

只需更改

MAIL_DRIVER=smtp

MAIL_DRIVER=sendmail

我不知道这是怎么回事的原因,但这对我来说很好

I don't know the reason How the hell is this working but it works fine for me