我想在发邮件前对每个邮件进行检查,应该如何操作?我查了api,有beforeSend() 方法和EVENT_BEFORE_SEND 事件,但是应该怎么用呢?我在main-local.php里企图向下面一样重写beforeSend方法,但是好像不行:
‘mailer’ => [
'class' => 'yii\swiftmailer\Mailer',
'viewPath' => '@common/mail',
'useFileTransport' => false,
**'beforeSend'=>function(){return true;}**
'transport' => [
'class' => 'Swift_SmtpTransport',
'host' => 'Host.COM',
'username' => 'test',
'password' => 'test',
'port' => 25,
],
'messageConfig'=> [
'charset' => 'UTF-8',
],
],
没试过,但是感觉可以结合
https://www.yiichina.com/doc/guide/2.0/structure-extensions#bootstrapping-classes
订阅全局事件