Laravel Failed to authenticate on SMTP server with username

Ripon Uddin picture Ripon Uddin · Oct 5, 2018 · Viewed 14.5k times · Source

Am trying to send email by Laravel. But It's getting error.

.env file Configuration below :

MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
[email protected]
MAIL_PASSWORD=******
MAIL_ENCRYPTION=tls

Controller Code Below :

 $data = array('name'=>"Ripon Uddin", "body" => "Test mail");

    Mail::send('email', $data, function($message) {
        $message->to('[email protected]','To My Yahoo')->subject('Laravel Test Email');
        $message->from('[email protected]','Ripon Uddin (Laravel Lover)');
    });

Error gettings :

Failed to authenticate on SMTP server with username "[email protected]" using 3 possible authenticators. Authenticator LOGIN returned Swift_TransportException: Expected response code 235 but got code "535", with message "535-5.7.8 Username and Password not accepted. Learn more at 535 5.7.8 https://support.google.com/mail/?p=BadCredentials r18-v6sm7406256pgv.17 - gsmtp " in

Answer

Haykins picture Haykins · May 24, 2020

you don't need to have GSuite to do this... I have done this integration alot of times with Laravel & GMail. Just go to your Google Account > Security > Less secure app access and Click on "Turn on access (not recommneded)"See image for more info