Laravel is sending mail using my old email configuration
Asked Answered
K

4

6

I've changed my e-mail configuration in the .env file but when I'm trying to send a mail, it's using my old configuration.

I've tried some commands:

php artisan clear-compiled, php artisan cache:clear, and php artisan config:clear but it still sending using my old email.

I also tried to change the password of my old Gmail account, but my site is just sending mail with my old mail account.

I've noticed this:

This message may not have been sent by: [redacted]@gmail.com Learn more Report phishing

on the received mail.

Krell answered 20/1, 2017 at 9:12 Comment(0)
S
31

If you're sending emails from a queue, try restarting the queue using php artisan queue:restart.

This fixed the issue for me. I had tried composer dump-autoload, php artisan clear-compiled, php artisan cache:clear, and php artisan config:clear as mentioned above but they didn't fix the issue in my case.

Synge answered 5/9, 2018 at 16:35 Comment(3)
Thanks. php artisan queue:restart worked. Apparently the command also remembers the views and the configs.Parenthesize
This was tricky to spot, thank you very much.Desiraedesire
this worked for me too. in my case, updated mail views were not getting picked up. instead the previous ones were being cache. no matter how many times i cleared the cache it didn't worked. thanks to you i used this command and now it works. Event gpt couldn't help. I have so much hope in humanity.Czardom
K
1

When you send email usually you would use some mail library and you get to choose ->from("[email protected]") parameter. This email object then gets sent using an email driver. The email driver then uses the environment settings to connect to an smtp account for e.g.

So changing the environmental variable will change the account which is the actual email sender but I assume you have forgotten to change the ->from("..") parameter.

This explains why you are seeing a notice saying this may not have been sebt by ...

Kynan answered 20/1, 2017 at 16:29 Comment(1)
I tried once again, everything is correct but I'm still getting the mail with the old email. In the local development I was using a Gmail account to send mail, now I already deployed my project and I decided to use my Domain email. The problem is my site is still using the old mail configuration. I even already changed the password of my Gmail but my site is still able to send mail using that Gmail instead of my domain emailKrell
R
0

Try clearing Config cache. I did using php artisan config:clear

Ransack answered 8/4, 2017 at 7:49 Comment(0)
C
0

After changing the new email configuration make sure to run this code in terminal

php artisan clear-compiled, php artisan cache:clear, and php artisan config:clear

Now email come from new configuration, but the from email and names are comes from old email configuration. But some times from new email and name.

So directly mention the email and name in email code not in .env or config file like this Mail::queue('emails.email_confirm', $data, function($message) use($user,$data) { $message->from(FROM_MAIL, FROM_MAIL_NAME)->to($user->email, $user->first_name)->subject($data['subject']); });

try this hereafter its working for me

Thank you....

Carse answered 12/7, 2018 at 5:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.