Reputation: 615
i using Mailer to send email, so i have problem about sender name This is my config
'mailer' => [
'class' => 'yii\swiftmailer\Mailer',
'useFileTransport' => false,
'messageConfig' => [
'charset' => 'UTF-8',
'from' => ['[email protected]' => 'App Sender Name'],
],
'transport' => [
'class' => 'Swift_MailTransport',
],
],
So it's not work. I goto inbox and only email showed.
Upvotes: 5
Views: 5429
Reputation: 615
it's work when i update setFrom() method. Ex: $mailer->setFrom(['[email protected]' => 'App Name']). And here is config Yii2 for send by PHP mail and with sender name
'mailer' => [
'class' => 'yii\swiftmailer\Mailer',
'useFileTransport' => false,
'messageConfig' => [
'charset' => 'UTF-8',
'from' => ['[email protected]' => 'App Sender Name'],
],
'transport' => [
'class' => 'Swift_MailTransport',
],
],
and send email
Yii::$app->mailer->compose()
->setTo('[email protected]')
->setFrom(['[email protected]' => 'App Name'])
....
Upvotes: 9
Reputation: 1684
Every component and sub-component in yii2 is configurable by dependency injection, this case is same, eg:
'transport' => [
'class' => 'Swift_SmtpTransport',
'host' => 'smtp.gmail.com',
'username' => '[email protected]',
'password' => '123456',
'port' => '465',
'encryption' => 'ssl',
],
Upvotes: 0