Unable to set the ‘FromName’ in email sent by SMTP

I am using SMTP to send emails in my custom module. But I am not able to set the ‘FromName’ of the email. I tried both hook_mail() and hook_alter_mail() but it is getting affected. My code is:

$ message[‘from’] = ‘sender name’; $ message[‘headers’][‘From’] = $ message[‘from’];

Email ‘From’ is getting set But not the ‘FromName’.