public function send()
{
$eventManager = $this->getManager()->getEventsManager();
if ($eventManager) {
$result = $eventManager->fire('mailer:beforeSend', $this);
} else {
$result = true;
}
if ($result === false) {
return false;
}
$this->failedRecipients = [];
$count = $this->getManager()->getSwift()->send($this->getMessage(), $this->failedRecipients);
if ($eventManager) {
$eventManager->fire('mailer:afterSend', $this, [$count, $this->failedRecipients]);
}
return $count;
}