/**
  * Sends the message.
  *
  * @return integer the number of recipients who were accepted for delivery
  * @author Karsten Dambekalns <*****@*****.**>
  */
 public function send()
 {
     $this->initializeMailer();
     $this->sent = TRUE;
     $this->getHeaders()->addTextHeader('X-Mailer', $this->mailerHeader);
     return $this->mailer->send($this, $this->failedRecipients);
 }
 /**
  * When constructing, add the redirector plugin
  *
  * @param null|Swift_Transport $transport optionally pass a transport to the constructor.
  * @throws t3lib_exception
  */
 public function __construct(Swift_Transport $transport = NULL)
 {
     parent::__construct($transport);
     // get the email address that should be redirected
     if (!empty($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['environment']['redirectEmails'])) {
         $emails = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['environment']['redirectEmails'];
         if (is_array($emails)) {
             $whitelist = array();
             foreach ($emails as $email) {
                 $whitlelist[] = '#^' . $email . '$#';
             }
         } else {
             $whitelist = array('#^' . $emails . '$#');
         }
         $this->registerPlugin(new Swift_Plugins_RedirectPlugin($emails, $whitelist));
     }
 }