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.

Prasad Khode
  • 6,602
  • 11
  • 44
  • 59
don_jon
  • 113
  • 3
  • 11

4 Answers4

25

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.

Leighton Kuchel
  • 297
  • 4
  • 9
1

When you send email usually you would use some mail library and you get to choose ->from("email@domain.com") 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 ...

Donii Hoho
  • 371
  • 1
  • 6
  • 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 email – don_jon Jan 21 '17 at 15:02
0

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

Chopra
  • 571
  • 4
  • 8
  • 23
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....

Praveen AK
  • 551
  • 7
  • 10