/** * Sends a single email. * @param EmailMessage $model the model instance. * @return integer the number of recipients. */ public function send(EmailMessage $model) { if ($this->logging) { $this->log(__CLASS__ . '.' . __FUNCTION__ . ':' . $model); } if (!$this->allowEmail($model->to)) { return -1; // not allowed to send } if ($this->dryRun) { return $model->getRecipientCount(); } // Get the Swift_Message $message = $model->getMessage(); if (isset($this->catchAllEmail)) { $message->setTo($this->catchAllEmail); $model->to = $this->catchAllEmail; $cc = $message->getCc(); if (!empty($cc)) { $message->setCc($this->catchAllEmail); $model->cc = $this->catchAllEmail; } else { $model->cc = null; } $bcc = $message->getBcc(); if (!empty($bcc)) { $message->setBcc($this->catchAllEmail); $model->bcc = $this->catchAllEmail; } else { $model->bcc = null; } } $recipientCount = $this->getMailer()->send($message, $this->_failedRecipients); $model->sentTime = date('Y-m-d H:i:s'); $model->save(false); return $recipientCount; }