/** * Create transport. * * @param Transport $transport The transport. * * @return mixed * * @SuppressWarnings(PHPMD.Superglobals) * @SuppressWarnings(PHPMD.LongVariable) */ public function createTransport(Transport $transport) { $transportFactoryClass = new \ReflectionClass($GLOBALS['AVISOTA_TRANSPORT'][$transport->getType()]); /** @var TransportFactoryInterface $transportFactory */ $transportFactory = $transportFactoryClass->newInstance(); return $transportFactory->createTransport($transport); }
/** * Set swift smtp on. * * @param \Swift_Transport $swiftTransport The swift transport. * @param Transport $transport The transport. * * @return void */ protected function setSwiftSMTPOn(&$swiftTransport, Transport $transport) { $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()); } }
public function createTransport(Transport $transport) { global $container; return $container[$transport->getServiceName()]; }
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); }