Forked from jack2jm/Send email using your gmail account in Laravel SMTP
Created
February 12, 2024 05:52
-
-
Save Bhavya8181/1535307296a5d85772f7219959562778 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 1. first login to your gmail account. | |
| 2. under Manage account > Sign In And Security > Sign In to google. | |
| 3. enable two step verification. | |
| 4. then you can generate app password. | |
| 5. you can use that app password in .env file. | |
| ---------------------------------------------- | |
| MAIL_DRIVER=smtp | |
| MAIL_HOST=smtp.gmail.com | |
| MAIL_PORT=587 | |
| MAIL_USERNAME=yourusername@gmail.com | |
| MAIL_PASSWORD=generate_app_password_from_security | |
| MAIL_ENCRYPTION=tls | |
| MAIL_FROM_ADDRESS=sender_email_name | |
| ------------------------------------------------ | |
| Route::get('/test-email', function () { | |
| try{ | |
| Mail::raw('Test Email!', function($message) { | |
| $message->to('sent_to_email_id')->subject('Testing mails'); | |
| }); | |
| echo "Sent..."; | |
| }catch(Exception $e){ | |
| echo $e->getMessage(); | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment