Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to send FROM name in email in laravel?

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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@example.com', $fromemailname); // Replace 'email@example.com' with the actual email address
    $message->to($emailid1);
});
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading