/**
  * Create the transport.
  *
  * @param Transport $transport The transport.
  *
  * @return SwiftTransport
  *
  * @SuppressWarnings(PHPMD.Superglobals)
  */
 public function createTransport(Transport $transport)
 {
     global $container;
     $swiftTransport = null;
     switch ($transport->getSwiftUseSmtp()) {
         case 'swiftSmtpSystemSettings':
             $this->setSwiftSMTPFromSystemSettings($swiftTransport);
             break;
         case 'swiftSmtpOff':
             $this->setSwiftSMTPOff($swiftTransport);
             break;
         case 'swiftSmtpOn':
             $this->setSwiftSMTPOn($swiftTransport, $transport);
             break;
     }
     $swiftMailer = \Swift_Mailer::newInstance($swiftTransport);
     $renderer = $container['avisota.transport.renderer'];
     if ($transport->getSetReplyTo()) {
         $renderer = new ReplyToOverwriteMessageRenderer($renderer, $transport->getReplyToAddress(), $transport->getReplyToName());
     }
     if ($transport->getSetSender()) {
         $renderer = new SenderOverwriteMessageRenderer($renderer, $transport->getSenderAddress(), $transport->getSenderName());
     }
     $renderer = new FromOverwriteMessageRenderer($renderer, $transport->getFromAddress(), $transport->getFromName());
     if ($GLOBALS['TL_CONFIG']['avisota_developer_mode']) {
         $renderer = new ToOverwriteMessageRenderer($renderer, $GLOBALS['TL_CONFIG']['avisota_developer_email'], null);
     }
     return new SwiftTransport($swiftMailer, $renderer);
 }
 public function createTransport(Transport $transport)
 {
     global $container;
     switch ($transport->getSwiftUseSmtp()) {
         case 'swiftSmtpSystemSettings':
             if ($GLOBALS['TL_CONFIG']['useSMTP']) {
                 $swiftTransport = \Swift_SmtpTransport::newInstance($GLOBALS['TL_CONFIG']['smtpHost'], $GLOBALS['TL_CONFIG']['smtpPort']);
                 if ($GLOBALS['TL_CONFIG']['smtpEnc'] == 'ssl' || $GLOBALS['TL_CONFIG']['smtpEnc'] == 'tls') {
                     $swiftTransport->setEncryption($GLOBALS['TL_CONFIG']['smtpEnc']);
                 }
                 if ($GLOBALS['TL_CONFIG']['smtpUser']) {
                     $swiftTransport->setUsername($GLOBALS['TL_CONFIG']['smtpUser']);
                     $swiftTransport->setPassword($GLOBALS['TL_CONFIG']['smtpPass']);
                 }
                 break;
             }
         case 'swiftSmtpOff':
             $swiftTransport = \Swift_MailTransport::newInstance();
             break;
         case 'swiftSmtpOn':
             $swiftTransport = \Swift_SmtpTransport::newInstance($transport->getSwiftSmtpHost(), $transport->getSwiftSmtpPort());
             if ($transport->getSwiftSmtpEnc()) {
                 $swiftTransport->setEncryption($transport->getSwiftSmtpEnc());
             }
             if ($transport->getSwiftSmtpUser() && $transport->getSwiftSmtpPass()) {
                 $swiftTransport->setUsername($transport->getSwiftSmtpUser());
                 $swiftTransport->setPassword($transport->getSwiftSmtpPass());
             }
             break;
     }
     $swiftMailer = \Swift_Mailer::newInstance($swiftTransport);
     $renderer = $container['avisota.transport.renderer'];
     if ($transport->getSetReplyTo()) {
         $renderer = new ReplyToOverwriteMessageRenderer($renderer, $transport->getReplyToAddress(), $transport->getReplyToName());
     }
     if ($transport->getSetSender()) {
         $renderer = new SenderOverwriteMessageRenderer($renderer, $transport->getSenderAddress(), $transport->getSenderName());
     }
     $renderer = new FromOverwriteMessageRenderer($renderer, $transport->getFromAddress(), $transport->getFromName());
     if ($GLOBALS['TL_CONFIG']['avisota_developer_mode']) {
         $renderer = new ToOverwriteMessageRenderer($renderer, $GLOBALS['TL_CONFIG']['avisota_developer_email'], null);
     }
     return new SwiftTransport($swiftMailer, $renderer);
 }