0

I have been having this issue with Laravel email with Gmail and I have checked and reviewed so many questions on Stack Overflow but none still works in my case. I am using Laravel 5.4 and Xampp.

At first I thought it was my Xampp that cannot allow sending the emails but also when I move to the live mode(hosted it on a shared hosting) still have same issues there as well

But whenever I set the configuration to use Mailtrap, it's working and I know mailtap is just a development mail server, but whenever I use the Gmail it give me error such as "Expected response code 220 but got code "", with message """

Also when I try it on live mode it still gives same error.

My configuration file has the following

.env

MAIL_DRIVER=smtp
MAIL_HOST=gmail-smtp-msa.l.google.com (also tried smtp.gmail.com)
MAIL_PORT=587
MAIL_USERNAME=email@gmail.com
MAIL_PASSWORD=password
MAIL_ENCRYPTION=ssl

mail.php

<?php

return [


    'driver' => env('MAIL_DRIVER', 'smtp'),

    'host' => env('MAIL_HOST', 'gmail-smtp-msa.l.google.com'),


    'port' => env('MAIL_PORT', 587),

    'from' => [
        'address' => 'email@gmail.com',
        'name' => 'Name Here',
    ],

    'encryption' => env('MAIL_ENCRYPTION', 'tls'),

     'username' => env('MAIL_USERNAME', 'email@gmail.com'),

    'password' => env('MAIL_PASSWORD', 'password'),



    'sendmail' => '/usr/sbin/sendmail -bs',
    'markdown' => [
        'theme' => 'default',

        'paths' => [
            resource_path('views/vendor/mail'),
        ],
    ],

];
halfer
  • 19,824
  • 17
  • 99
  • 186
  • Did you try php artisan config:cache and php artisan config:clear – Maraboc Sep 20 '17 at 09:40
  • Please read [Under what circumstances may I add “urgent” or other similar phrases to my question, in order to obtain faster answers?](//meta.stackoverflow.com/q/326569) - the summary is that this is not an ideal way to address volunteers, and is probably counterproductive to obtaining answers. Please refrain from adding this to your questions. – halfer Sep 20 '17 at 11:34

2 Answers2

0

Hey here is the solution

MAIL_DRIVER='smtp

MAIL_HOST='smtp.gmail.com'

MAIL_PORT=587

MAIL_USERNAME='sample@gmail.com'

MAIL_FROM_ADDRESS='sample@gmail.com'

MAIL_FROM_NAME='Some Name'

MAIL_PASSWORD='XXXXX'

MAIL_ENCRYPTION='tls'

Naveen
  • 221
  • 2
  • 3
0

As well as the configuration on the Laravel side, you need to enable "Less secure apps" in your Gmail account.

On the Laravel side, this guide shows the settings you need. Use smtp.gmail.com for host, and either 465/ssl or 587/tls.

Don't Panic
  • 13,965
  • 5
  • 32
  • 51