Search code examples
phplaravel-5gmailswiftmailer

Gmail setup for laravel 5 mail send


I set this up to send mail by laravel 5 from my gmail account.

MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=********@gmail.com //email address
MAIL_PASSWORD="*******" //password for that email
MAIL_ENCRYPTION=tls

To test the mail sending, I used this one

Route::get('/email', function(){
$data = array(
    'name' => "Library",
    );
Mail::send('mailview',$data,function($message){
    $message->from('*******@gmail.com','Library');
    $message->to('*******@gmail.com')->subject('Confirmation mail.');
});

return "A email has been sent to you. Check inbox. Also check spambox if not in inbox.";});

But this gives me the following error.

Swift_TransportException in AbstractSmtpTransport.php line 383: Expected response code 250 but got code "530", with message "530 5.7.0 Must issue a STARTTLS command first. g20sm4065212pfd.55 - gsmtp "

I googled for this and found some questions on SO related to this. And understood so far that the settings for gmail security is the culprit here.But didn't found any answer which describes what to do to solve this. Now I want to know how should I configure my gmail account? [Let's assume I have just created a new gmail account.Working on linux mint-if this info help you in anyway.]


Solution

  • Not sure what happened.

    port 587 should work.

    Will you try by creating a new project and configure the settings like you wrote here?

    I think everything here is okay. There may be other issue(s) with your project settings.

    Once I faced something like this and creating a new project worked for me.