This post will help you to fix issue like
Error : Swift_TransportException in StreamBuffer.php line 268:
Connection could not be established with host smtp.gmail.com [Connection refused #111]
Sending emails is crucial for any web application. Usually, an email is sent to notify the user of some kind of activity.Here are the steps to send email in laravel using Gmail SMTP.
Generally Gmail is not recommended to send emails on live server, but if you just using it for testing purpose then follow these steps:
1. Visit https://myaccount.google.com/security make sure you have allowed
less secure app
to YES.
2. Unlock captcha on https://accounts.google.com/b/0/DisplayUnlockCaptcha.
3. Generate APP password
- Turn on 2-Step Verification for your account https://myaccount.google.com/security.
- Your app might not support the latest security standards. Try changing a few settings to allow less secure apps access to your account.
- After enabling 2-Step Verification, APP password option will be visible under Signing in to google
- Create APP password
4. Update your .env to
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=465
MAIL_USERNAME=email@gmail.com
MAIL_PASSWORD=APP_PASSWORD // created in step 3
MAIL_ENCRYPTION=ssl
5. run
php artisan config:cache
after you make changes in your .env
file.
After performing above actions email should work fine.
Comments
Post a Comment