Step: 1 Obtain Gmail SMTP Credentials
Firstly, we need to have a Gmail account. If you're using this for a production environment, it might be wise to create a dedicated account. Once you have your account, you need to generate an app-specific password. This is a more secure way of using Gmail SMTP, as it doesn't involve using your actual Gmail password. To generate an app-specific password, go to your Google Account settings, navigate to the "Security" tab, and under "Signing in to Google," choose "App passwords." You may need to sign in again. Select the app and device you want to generate the password for and follow the prompts.
Add the below code in the .env file
We need to update our Gmail username and password.
Note: For enhanced security, it's recommended to generate an App Password if you have 2-Step Verification enabled on your Google account.
We need to update our Gmail username and password.
Note: For enhanced security, it's recommended to generate an App Password if you have 2-Step Verification enabled on your Google account.
Step 2: Configure Laravel Environment
Step: 3 Update config/mail.php
Step: 4 Sending email in Laravel controller
Controller
Simply update $to_email your email where you want to have an email.
The above code will send an email using gmail smtp settings.
No comments:
Post a Comment