gpt4 book ai didi

laravel - laravel 中的 Swift_TransportException 错误

转载 作者:行者123 更新时间:2023-12-02 15:53:22 25 4
gpt4 key购买 nike

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

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 "

这是我的 Controller

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

{{ 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()}}

邮件.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,

最佳答案

在 Laravel 5 中,问题来自于 .env 文件。 Laravel 附带了一个加密值集,该值会覆盖 config/mail.php 中的默认设置。在 .env 中,将 MAIL_ENCRYPTION=null 更改为 MAIL_ENCRYPTION=tls 就可以了。

关于laravel - laravel 中的 Swift_TransportException 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26277103/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com