Laravel 5.5 发送邮件
Laravel 5.5 Send MAil
我试图从本地主机向我的电子邮箱发送一封电子邮件,但我总是收到此错误
无法与主机建立连接 smtp.gmail.com在你的连接期间不确定,你的车在连接时没有连接。 #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
您使用了错误的邮件端口。端口 2525
用于 Mailtrap,对于 Google 它应该是 587
对于 MAIL_PORT
我试图从本地主机向我的电子邮箱发送一封电子邮件,但我总是收到此错误
无法与主机建立连接 smtp.gmail.com在你的连接期间不确定,你的车在连接时没有连接。 #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
您使用了错误的邮件端口。端口 2525
用于 Mailtrap,对于 Google 它应该是 587
对于 MAIL_PORT