1

For my website I try to send emails from an alias (created alias from google for business). My mail function:

Mail::send('emails.tracktrace', ['text'=>$mailtext,'tracking' => $code,'email' => $email, 'name' => $name], 
function ($m) use ($code, $email, $name) {
        $m->from('info@mydomain.eu', 'Mydomain');
        $m->to($email, $name)->subject('Track your package!');
});

Also in my config/mail.php I have:

'from' => ['address' => 'noreply@mydomain.eu', 'name' => 'mydomain'],

But both are ignored and the MAIL_USERNAME value set in my .env file (with the mail configuration) is used.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Sven van den Boogaart
  • 11,833
  • 21
  • 86
  • 169
  • what is your mail_host, mail_port? can you make sure mail_username and mail_password already correct? – ssuhat Dec 31 '15 at 17:05
  • @sstarlight everything works the mail is send. But the sender is never changed – Sven van den Boogaart Dec 31 '15 at 17:06
  • as far i read your code it should working properly. I never tried google for business to send via laravel. But as far as i know it should be working. try change `$m` to `$message` and remove `from` mail or the function (so only use 1 `from`) – ssuhat Dec 31 '15 at 17:14

1 Answers1

1

I ran into the same problem.. Turned out I tried to use a Gmail account which doesn't let you change the 'from' headers. (see problem with php mail 'From' header)

Community
  • 1
  • 1
Arno van Oordt
  • 2,912
  • 5
  • 33
  • 63