Laravel 中的 Swift_TransportException 错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26277103/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Swift_TransportException error in laravel
提问by user3656554
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
Expected response code 250 but got code "530", with message "530 5.7.0 Must issue a STARTTLS command first. bv17sm3597476wib.13 - gsmtp "
Swift_TransportException
预期响应代码 250,但得到代码“530”,消息为“530 5.7.0 必须先发出 STARTTLS 命令。bv17sm3597476wib.13 - gsmtp”
This is my controller
这是我的控制器
public function contact()
{
$data = array(
'name' => Input::get('name')
);
Mail::send('emails.contact', $data, function($message){
$message->to('[email protected]', 'Nikki')->subject('Login Details');
});
}
and this is my contact.blade.php
这是我的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
邮件.php
'driver' => 'smtp',
'host' => 'smtp.gmail.com',
'port' => 587,
'from' => array('address' => '[email protected]', 'name' => "Nikki"),
'encryption' => 'tls',
'username' => '[email protected]',
'password' => 'MyPassword',
'sendmail' => '/usr/sbin/sendmail -bs',
'pretend' => false,
回答by PapaHotelPapa
In Laravel 5, the problem comes from the .env
file. Laravel ships with a value set for encryption there that overrides your default setting in config/mail.php
. In .env
, change MAIL_ENCRYPTION=null
to MAIL_ENCRYPTION=tls
and you're good to go.
在 Laravel 5 中,问题来自于.env
文件。Laravel 附带了一个用于加密的值集,它会覆盖config/mail.php
. 在 中.env
,更改MAIL_ENCRYPTION=null
为MAIL_ENCRYPTION=tls
,您就可以开始了。
回答by androsfat
When changing the .env
you need to restart your server
更改.env
时需要重新启动服务器
回答by Ahamed Rasheed
Check your .env
file.
检查您的.env
文件。
I was using mailgun
我正在使用邮件枪
MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailgun.org
MAIL_PORT=1230
[email protected]
MAIL_PASSWORD=your_password
MAIL_ENCRYPTION=tls
[email protected]
MAILGUN_SECRET=null
I had the same problem, My fault was MAIL_ENCRYPTION
was given a wrong input.
我有同样的问题,我的错是MAIL_ENCRYPTION
输入错误。
回答by José
When changing the .env
you need to restart your server or in linux terminal runs
更改.env
时需要重新启动服务器或在 linux 终端运行
php artisan config:cache
回答by MH Fuad
change your mail driver in .env file "smtp to sendmail" it works in my case.
在 .env 文件“smtp to sendmail”中更改您的邮件驱动程序,它适用于我的情况。
MAIL_DRIVER=sendmail