YII2 email configuration, the online method is ineffective!

Source: Internet
Author: User
Check my configuration item {code...} And then upload my sending code {code...}. How can I test it? Is my posture incorrect ?! First go to my Configuration item

'mailer' => [        'class' => 'yii\swiftmailer\Mailer',        'viewPath' => '@common/mail',        'useFileTransport' => true,        'transport' => [            'class' => 'Swift_SmtpTransport',            'host' => 'smtp.163.com',            'username' => 'username@163.com',            'password' => 'myPassword',            'port' => '994',            'encryption' => 'ssl',        ],    ],

Then go to mySend code

return \Yii::$app->mailer->compose('passwordResetToken', ['user' => $user])    ->setFrom([\Yii::$app->params['supportEmail'] => \Yii::$app->name . ' robot'])    ->setTo($this->email)    ->setSubject('Password reset for ' . \Yii::$app->name)    ->send();

The test is invalid. Is it me?PostureNo ?!

Reply content:

First go to myConfiguration item

'mailer' => [        'class' => 'yii\swiftmailer\Mailer',        'viewPath' => '@common/mail',        'useFileTransport' => true,        'transport' => [            'class' => 'Swift_SmtpTransport',            'host' => 'smtp.163.com',            'username' => 'username@163.com',            'password' => 'myPassword',            'port' => '994',            'encryption' => 'ssl',        ],    ],

Then go to mySend code

return \Yii::$app->mailer->compose('passwordResetToken', ['user' => $user])    ->setFrom([\Yii::$app->params['supportEmail'] => \Yii::$app->name . ' robot'])    ->setTo($this->email)    ->setSubject('Password reset for ' . \Yii::$app->name)    ->send();

The test is invalid. Is it me?PostureNo ?!

'Usefiletransport '=> true,

Change to false. If it is true, ONLY emails are generated at runtime.

I think Yii2 is not very stable yet. Currently, it cannot be used in the production environment.

It seems that the email address set by \ Yii: $ app-> mailer's setFrom () must be the same as the email address in the configuration.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.