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 "
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
{{ 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' => '[email protected]', 'name' => "Nikki"),
'encryption' => 'tls',
'username' => '[email protected]',
'password' => 'MyPassword',
'sendmail' => '/usr/sbin/sendmail -bs',
'pretend' => false,
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.
When changing the .env
you need to restart your server
change your mail driver in .env file "smtp to sendmail" it works in my case.
MAIL_DRIVER=sendmail
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With