关注this guide我已经设置了一个事件监听器:
<?php
class EmailListener implements \Swift_Events_SendListener
{
public $beforeSendEvt = null;
public $sendEvt = null;
public function beforeSendPerformed(\Swift_Events_SendEvent $evt)
{
$this->beforeSendEvt = $evt;
}
public function sendPerformed(\Swift_Events_SendEvent $evt)
{
$this->sendEvt = $evt;
}
}
现在,我想以beforeSendPerformed
方式取消此电子邮件。我该怎么做?
答案 0 :(得分:4)
大概:
$evt->cancelBubble();
https://github.com/swiftmailer/swiftmailer/blob/613354e08fbddce0943646932b007be9873c658f/lib/classes/Swift/Transport/AbstractSmtpTransport.php#L155-L158 https://github.com/swiftmailer/swiftmailer/blob/613354e08fbddce0943646932b007be9873c658f/lib/classes/Swift/Events/EventObject.php#L44-L62