To use a Google App Password with Laravel 8’s .env
email SMTP configuration, you’ll need to set up an App Password in your Google account and then configure your Laravel application. Here are the steps:
- Create a Google App Password:
- Log in to your Google account.
- Go to your Google account settings.

- Search for App Password, then click on App Password in drop-down menu

- Enter App name

- Click “Create.” Google will generate a 16-character App Password that you should copy. Keep this password secure, as you won’t be able to see it again.

- Update Laravel’s .env File: Open your Laravel project’s
.env
file and configure the SMTP settings to use the App Password:

Password generated in the previous step.
- Less Secure Apps and Your Google Account: By default, Google may block sign-ins from apps that it considers less secure. Since Laravel uses SMTP to send emails, you might need to enable “Less secure apps” in your Google account settings. To do this:
- Go to your Google Account settings.
- In the “Security” section, find the “Less secure app access” option.
- Turn on the “Allow less secure apps” toggle. Keep in mind that enabling “Less secure apps” makes your account potentially less secure. It’s recommended to use two-factor authentication and only enable this option temporarily for your application.
- Clear Configuration Cache: After updating your
.env
file, you should clear your configuration cache to ensure Laravel uses the new settings:
PHP
php artisan config:cache
- Testing: You can now test your email sending functionality in Laravel to ensure that it’s using the Google App Password for authentication. You can send a test email to confirm that everything is working as expected.
That’s it! You’ve configured Laravel to use a Google App Password for SMTP email authentication. Remember to keep your App Password secure, as it provides access to your Gmail account for sending emails.