Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

rafaelg21's avatar

Configure email reset_password smtp gmail

Good morning greetings to all, I have a problem with my gmail smtp and laravel to upload to production on your server, local using xampp works fine and sends me the mails but in production does not send anything but sends me the following error . What can this error be? do I need to configure something on the server?

Expected response code 250 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 f66sm1199913qkc.25 - gsmtp
"

While on my local server does not throw any error and in gmail was already disabled the two-step verification that had been a problem to test on my local server and also enable Allow access for less secure applications: YES

Just set up the .env and the config / mail.php file and this way it works on localhost with my xampp

.env

MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=*****@gmail.com
MAIL_PASSWORD=*****
MAIL_ENCRYPTION=tls

config/mail.php

return [

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

    'host' => env('MAIL_HOST', 'smtp.gmail.com'),

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

    'from' => [
        'address' => env('MAIL_FROM_ADDRESS', '*****@gmail.com'),
        'name' => env('MAIL_FROM_NAME', 'MiNombre MiApellido'),
    ],

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

    'username' => env('MAIL_USERNAME'),

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

    'sendmail' => '/usr/sbin/sendmail -bs',

    'markdown' => [
        'theme' => 'default',
        'paths' => [
            resource_path('views/vendor/mail'),
        ],
    ],
];

Thank you very much, I hope you can help me.

0 likes
2 replies
rafaelg21's avatar
rafaelg21
OP
Best Answer
Level 1

Find this solution from this post.

https://stackoverflow.com/questions/25193467/gmail-locks-account-when-sending-mail-via-laravel

  1. You must turn on Gmail two-step authentication. https://myaccount.google.com/signinoptions/two-step-verification

  2. Then add an Application Passwords. https://myaccount.google.com/apppasswords

    Select application> Mail, Select Devices> Other, Name> myproyectlaravel

Once created that application password should copy and paste as your password in the .env

And that's it, that works for me.

3 likes
Angelo90's avatar

Hii, I'm trying to do that but I have the problem in my localhost server. My .env is like yours of above (with diferent gmail account and pass). Then when I try to send the request, it returns me this error:

stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages: error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed

I know that my localhost has not ssl, but but I guess you did not configure an ssl certificate in your local environment, or am I wrong?

PD: I am using Laravel 5.7

Please or to participate in this conversation.