在 common/config/main-local.php中写入以下代码配置 Mail代理
return [ 'components' => [ ...//your code, //以下是 mail 的配置 'mailer' => [ 'class' => 'yii\swiftmailer\Mailer', 'viewPath' => '@common/mail', 'transport' => [ 'class' => 'Swift_SmtpTransport', //我用的是QQ 的代理,所以这里是 QQ 的配置信息 'host' => 'smtp.qq.com', 'port' => 587, 'encryption' => 'tls', //这部分信息不应该公开,所以后期会由数据库中拿取 'username' => '你的 QQ 号', 'password' => '你的 QQ 密码', ], //发送的邮件信息配置 'messageConfig' => [ 'charset' => 'utf-8', 'from' => ['83398365@qq.com' => 'BugAsk'] ], ],' ] ];