Swift_TransportException error in laravel

I am trying to create a contact form that sends a message to my email address. When I checked this I got this error

Swift_TransportException

The expected response code is 250, but received the code "530", with the message "530 5.7.0" First, must issue the STARTTLS command. 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('test@gmail.com', 'Nikki')->subject('Login Details');
            });
}

      

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,

      

+3


source to share


1 answer


In Laravel 5, the problem comes from a file .env

. Laravel sends the value set for encryption there, which overrides the default setting in config/mail.php

. The .env

change MAIL_ENCRYPTION=null

to MAIL_ENCRYPTION=tls

, and you're good to go.



+1


source







All Articles