How can I set the email sender name? below code is not working in our custom module.

$site_name = \Drupal::config('system.site')-&gt;get('name');
$site_mail = \Drupal::config('system.site')-&gt;get('mail');

$message['headers']['From'] = $site_name . ' &lt;' . $site_mail . '&gt;';
$message['headers']['Sender'] = $message['headers']['Return-Path'] = $site_mail;
$message['from'] = $site_name . ' &lt;' . $site_mail . '&gt;';

It gives the output like this : 

 MailSender &lt;MailSender&gt; &lt;email@example.com&gt;


and I want the output like this : 

MailSender &lt;email@example.com&gt;


How can I do this?
If you look at your code and the output you wrote, it come clearly out, that either:


$message['headers']['From'] = $site_name . ' &lt;' . $site_mail . '>';
$message['from'] = $site_name . ' &lt;' . $site_mail . '>';


is not working at all. 

I would get rid of the unnecessary code first, and then trying to modify the working line.