Ali Özen
Ali Özen

Reputation: 1609

How to send email without enabling "Access for less secure apps"

In my mail configurations:

MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
[email protected]
MAIL_PASSWORD=lol
MAIL_ENCRYPTION=tls

But my testing email was enabled for "access for less secure apps". Is there a chance to send email to any types of email? Currently, I can't get a server email and they configuration. I need to create my own email and integrate to the website.

My searches give me "2-step verification". Is system can automatically send emails If I enabled this? I can't get any solution. I hope somebody can help me. Thanks in advance.

Upvotes: 4

Views: 5748

Answers (1)

Adam Kozlowski
Adam Kozlowski

Reputation: 5896

  1. Log to your gmail account
  2. My account > Sign In And Security > Sign In to google
  3. Enable two step verification, then you can generate app password
  4. You can use that app password in .env file.

.env will look like

MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
[email protected]
MAIL_PASSWORD=pass
MAIL_ENCRYPTION=tls

If you got error Expected response code 220 but got code remember to clear cache after any changes in .env file:

php artisan config:cache

Upvotes: 15

Related Questions