I want to send emails through my host email that is : admin@b4p.et
I have passing this email in from email id but this is sending mails from the SMTP username which i have configured in common/config/main.php
Following is my mail configurations in common/config/main.php :
'mailer' => [
'class' => 'yii\swiftmailer\Mailer',
'viewPath' => '@common/mail',
'useFileTransport' => false,
'transport' => [
'class' => 'Swift_SmtpTransport',
'host' => 'smtp.gmail.com',
'username' => 'chiefsrsmail@gmail.com',
'password' => '*********',
'port' => '587',
'encryption' => 'tls',
],
],
And following is my send mail function :
public static function sendMailToUser($ssToEmail, $asFromEmail, $ssSubject, $ssBody, $attach = false)
{
$result = Yii::$app->mail->compose()
->setFrom([$asFromEmail])
->setTo($ssToEmail)
->setSubject($ssSubject)
->setHtmlBody($ssBody)
->send();
return true;
}
In which i am passing :
$asFromEmail = admin@b4p.et
This function works fine for sending emails but the all emails are going through "chiefsrsmail@gmail.com" means all emails takes from email address from SMTP username which i have provided in configuration.I want to change it but it is not working.
Please help me to get out of this.