John Davidson

php - laravel 9 smtp gmail .env setup

0 comments
Message:


i am a bit stuck here, I have done this before, so I have a registration form that sends mail after the registration is completed , I have tested with default mailtrap and it works, i just have to replace the details to Gmail. and I have done it all, it turns out Gmail has turned of less secure feature from the Gmail setting, these settings allow less secure apps to send mails


here is my .env config


MAIL_MAILER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=465
MAIL_USERNAME=my email
MAIL_PASSWORD=
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS="my email"
MAIL_FROM_NAME="${APP_NAME}"


i have also tried creating an app password and replacing that with the password above , it doesnt work , i get the error


Failed to authenticate on SMTP server with username "[email protected]" using the following authenticators: "LOGIN", "PLAIN", "XOAUTH2". Authenticator "LOGIN" returned "Expected response code "235" but got code "534", with message "534-5.7.9 Application


please i need any suggestion . thanks



My Answer:
It looks like you are facing an authentication issue with Gmail SMTP. Here are a few things you can try:

1. Enable "Allow less secure apps" in your Gmail account settings:
- Go to your Google Account settings
- Click on Security
- Scroll down to "Less secure app access" and turn it on

2. Use an app password instead of your regular Gmail password:
- Generate an app password for your Gmail account
- Use this generated password in your .env file instead of your regular Gmail password

3. Make sure you have the correct port and encryption settings:
- Try using port 587 with encryption set to "tls" instead of port 465
- Update your .env file accordingly

4. Double-check your Gmail username:
- Make sure you are using the full Gmail email address as the username in your .env file

After making these changes, try sending an email again and see if it works. If you are still facing issues, you may need to check your Gmail account settings or consult with Google support for further assistance.

Rate this post

3 of 5 based on 5537 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us