Laravel中的Swift_TransportException错误 [英] Swift_TransportException error in laravel

查看:189
本文介绍了Laravel中的Swift_TransportException错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个联系表单,将邮件通过电子邮件发送到我的电子邮件地址.当我测试出来时,我得到了这个错误

I'm trying to create a contact form that email the message to my email address. When I tested it out I got this error

Swift_TransportException

Swift_TransportException

预期的响应代码为250,但代码为"530",消息为"530 5.7.0,必须首先发出STARTTLS命令.bv17sm3597476wib.13-gsmtp"

Expected response code 250 but got code "530", with message "530 5.7.0 Must issue a STARTTLS command first. bv17sm3597476wib.13 - gsmtp "

这是我的控制器

public function contact()
{

     $data = array(
                'name' => Input::get('name')
                );


            Mail::send('emails.contact', $data, function($message){
                $message->to('test@gmail.com', 'Nikki')->subject('Login Details');
            });
}

这是我的contact.blade.php

and this is my contact.blade.php

{{ Form::open(array('id' => 'contact-frm', 'class' => 'contact-form', 'route' => 'contact')) }}
{{ Form::label('fname', 'Name') }}
{{ Form::text('fname') }}

{{ Form::label('surname', 'Surname') }}
{{ Form::text('surname') }}

{{ Form::label('email', 'Email') }}
{{ Form::text('email') }}

{{ Form::label('message', 'Message') }}
{{ Form::textarea('message') }}

{{ Form::submit('Submit') }}
{{ Form::close()}}

mail.php

'driver' => 'smtp',
'host' => 'smtp.gmail.com',
'port' => 587,
'from' => array('address' => 'myEmail@gmail.com', 'name' => "Nikki"),
'encryption' => 'tls',
'username' => 'myEmail@gmail.com',
'password' => 'MyPassword',
'sendmail' => '/usr/sbin/sendmail -bs',
'pretend' => false,

推荐答案

更改.env时,您需要重新启动服务器

When changing the .env you need to restart your server

这篇关于Laravel中的Swift_TransportException错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆