How to send FROM name in email in laravel?

88 Views Asked by At

I am using Laravel with Mailable class for sending emails with HTML content it is sending, but I am receiving mail with an email address, but I need a name. Still, it's not helpful. Can anyone explain where I made a mistake?

Mail::html($template,function($message) use($emailid1,$subject,$fromemailname){
    $message->subject($subject);
    $message->from($fromemailname,'TEST');
    $message->to($emailid1);
});

I am expecting an email from TEST. I tried to override the mail config, too, but I am still receiving with an email address only.

1

There are 1 best solutions below

0
Karl Hill On BEST ANSWER

The from method of the Message class takes two parameters: the email address and the sender's name. You might have swapped the order of these parameters in your code. Make sure the email address comes first, followed by the name.

Mail::html($template, function($message) use($emailid1, $subject, $fromemailname) {
    $message->subject($subject);
    $message->from('[email protected]', $fromemailname); // Replace '[email protected]' with the actual email address
    $message->to($emailid1);
});