Sending emails through Gmail in Laravel
Sending emails through Gmail in Laravel
Contents
Sending emails through Gmail in Laravel is straightforward and requires a few setup steps to integrate Gmail’s SMTP server with your Laravel application.
1 Step 1: Create app password for Gmail:
- Logging into your Google account.
- Navigate to Security settings, then select 2-Step Verification.
- At the bottom of page, choose App passwords.
- Generate a new app password. This password will be used in your Laravel application’s configuration.
- Notice information from Google: App passwords help you sign into your Google Account on older apps and services that don’t support modern security standards. App passwords are less secure than using up-to-date apps and services that use modern security standards. Before you create an app password, you should check to see if your app needs this in order to sign in.
2 Step 2: Edit your .env
file:
|
|
Replace your-email@gmail.com
with your Gmail address and YOUR-APP-PASSWORD
with the app password you generated.
3 Step 3: Send a test email from Tinker:
- Open your terminal and run
php artisan tinker
. - Use the following code to send a test email:
|
|
Replace 'recipient@gmail.com'
with the right email address.