我试图从localhost发送电子邮件到我的电子邮件但是我得到了这个错误
无法与主机smtp.gmail.com建立连接[Une tentative de connexiona chou carleparticonnect n aposr ponduconvenablementau-del d uneutainedur e ou uneconnexion lielie de de de de de de de de dedududududududududududududududududududududududududududududududududududududududu #10060] 我没有找到任何解决方案 this is a screen shot for the error
这是控制器代码
public function contact_sent(Request $request)
{
$emails = "mohamedfarjallah8@gmail.com";
$messages = "This body message......";
$subject = "This is subject from email";
$fromEmail = "mohamedfarjallah8@gmail.com";
$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
MAIL_USERNAME=mohamedfarjallah8@gmail.com
MAIL_PASSWORD=**************
MAIL_ENCRYPTION=tls
答案 0 :(得分:0)
您使用的是错误的邮件端口。端口2525
适用于Mailtrap,对于Google,587
适用于MAIL_PORT