YII2邮件配置,网上方法不凑效!


先上我的 配置项


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

然后上我的 发送代码


 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();

怎么测试都无效,是不是我 姿势 不对?!

yii 框架 yii2 php phpmailer

梅尔西迪斯 10 years, 2 months ago

'useFileTransport' => true,

改为false ,如果是true只是生成邮件 在runtime下

沙包大萌神 answered 10 years, 1 month ago

Your Answer