需要设置全局报警设置需要使用stmp 邮件代理,这里使用yii2 2.0.12
我使用的是qq邮箱为例
账号:qq号@qq.com
密码:邮箱授权码,具体获取在账号设置中,可以进行短信重置授权码
port:587
其中 EmailTarget 有demo
配置实例=》comm->main-local.php
'components' => [ 'mailer' => [ 'class' => 'yii\swiftmailer\Mailer', 'viewPath' => '@common/mail', // send all mails to a file by default. You have to set // 'useFileTransport' to false and configure a transport // for the mailer to send real emails. 'useFileTransport' => false, 'transport' => [ 'class' => 'Swift_SmtpTransport', 'host' => 'smtp.qq.com', 'username' => '******@qq.com', 'password' => '******', 'port' => '587', 'encryption' => 'tls', ], 'messageConfig' => [ 'charset' => 'UTF-8', 'from' => ['******@qq.com' => '****授权码**'] ], ], 'log' => [ 'targets' => [ [ 'class' => 'yii\log\EmailTarget', 'mailer' => 'mailer', 'levels' => ['error', 'warning'], 'message' => [ 'from' => ['*****发送者邮箱*****'],
'to' => ['*****接收者邮箱*****', '*****接收者邮箱*****'],
'subject' => '全局异常捕获', ], ], ], ], ],