Laravel 5.5发送邮件

问题描述 投票:0回答:1

我试图从localhost发送电子邮件到我的电子邮件,但我总是收到此错误

连接尝试失败,因为连接的一方在一定时间内没有正确响应或建立了连接。失败,因为登录主机没有响应。 #10060]我没有找到任何解决方案 this is a screen shot for the error

这是控制器代码

public function contact_sent(Request $request)
{
    $emails = "[email protected]";
    $messages = "This body message......";
    $subject = "This is subject from email";
    $fromEmail = "[email protected]";

    $data = array('emails'=>$emails,'messages'=>$messages,'fromEmail'=>$fromEmail,'subject'=>$subject);
    Mail::send([],$data, function ($message) use ($data) {
                     $message->from($data['fromEmail'],'SubText that show in header part of email');
                     $message->to($data['emails'])->setBody($data['messages']);
                     $message->subject($data['subject']);
                     $message->replyTo($data['fromEmail'],'Some text you can test this');

            });

            echo "Ok you can check your email";exit;
}

这是.env配置

MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=2525
[email protected]  
MAIL_PASSWORD=**************
MAIL_ENCRYPTION=tls
laravel email web smtp laravel-5.5
1个回答
0
投票

您使用的是错误的邮件端口。端口2525用于Mailtrap,对于谷歌它应该是587用于MAIL_PORT

© www.soinside.com 2019 - 2024. All rights reserved.