I am sending the email using below code
Mail::send('emails.sample',[],function($message) use($attachment,$filename)
{
$message->subject('PDF is generated !');
$message->from('[email protected]', 'Example');
$message->to('[email protected]');
$message->attachData($attachment,$filename,array('mime'=>'application/pdf','Content-Disposition'=>'attachment'));
});
but after receiving the email, sender email address is coming like this
[email protected] on behalf of Example [email protected]
but it should be like either email address or name
[email protected]
How do I fix this? any suggestions, please!
For anyone still reading this - it's because you need to set the "sender" address. Gmail doesn't seem to care, but Outlook does.
$message->sender(config('mail.from.address'));
you can add these in .env:
[email protected]
MAIL_FROM_NAME=From Name Surname
in alternative, if you let it blank, you can still change them in config/mail.php, here replace with yours:
'from' => [
'address' => env('MAIL_FROM_ADDRESS', '[email protected]'),
'name' => env('MAIL_FROM_NAME', 'IDesk'),
],
as you can see config/mail.php at first try to read it from .env sto .env should be used
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With