Home > Mobile >  How can I send emails drirectly to users with laravel?
How can I send emails drirectly to users with laravel?

Time:10-06

I have a laravel project, this project has "forgot password" plugin. But when i send reset link to users mail, this link doesnt go to the user mail's inbox. It goes to the my smtp account. I am using mailtrap for testing. I want to be able to send mail directly to user's email. Is it possible to do that with codes. Or should i forward to emails. And how can i do that ? What am i doing wrong ?

What email address they type in this input, reset link should go that email not my mailtrap account.

My reset email link

Password reset link comes here. I dont want that. It has to send reset link to user's email not my mailtrap account.

Email comes here.

Last step should be same but we have to come here from user's email.

enter image description here

CodePudding user response:

You're using mailtrap at the moment. This doesn't send any emails to the real world. To receive an email, you must configure correspondence in your .env file.

Default .env

MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null

ex: for Gmail

MAIL_MAILER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=465
[email protected]
MAIL_PASSWORD=password
MAIL_ENCRYPTION=tls
[email protected]
MAIL_FROM_NAME="${APP_NAME}"

Check this example - Laravel 9 Send Mail using Gmail SMTP Server and for configurations

CodePudding user response:

I changed password and enabled 2-step verification.

  1. enable the 2-step verification to google

  2. Create App Password to be use by your system

I did those and it worked

  • Related