__construct() 공개 메소드

Create a new Mailer using $transport for delivery.
public __construct ( Swift_Transport $transport )
$transport Swift_Transport
예제 #1
0
 /**
  * @param Swift_Transport $transport the transport method to use
  * @param array $options sets the class properties passed in as and array
  */
 public function __construct(Swift_Transport $transport, $options)
 {
     foreach ($options as $key => $option) {
         $this->{$key} = $option;
     }
     parent::__construct($transport);
 }
예제 #2
0
 public function __construct(Swift_Transport $transport = null)
 {
     if (!$transport) {
         $transport = Swift_MailTransport::newInstance();
         // set transport from config (see method send)
         $this->wa_set_transport = true;
     }
     parent::__construct($transport);
 }
예제 #3
0
파일: Mailer.php 프로젝트: Eximagen/sochi
 /**
  *
  * @param \Swift_Transport $transport
  */
 public function __construct(\Zend_Config $webconfig)
 {
     $this->setWebconfig($webconfig);
     if (null === $transport) {
         $transport = $this->createTransport();
     }
     parent::__construct($transport);
     \Swift_Preferences::getInstance()->setCharset('iso-8859-1');
 }
예제 #4
0
파일: Mailer.php 프로젝트: cargomedia/cm
 /**
  * @param Swift_Transport $transport
  * @param array|null      $headers
  */
 public function __construct(Swift_Transport $transport, array $headers = null)
 {
     if (null === $headers) {
         $headers = [];
     }
     $this->_headers = $headers;
     CM_Mail_Message::register();
     parent::__construct($transport);
 }
예제 #5
0
파일: Mailer.php 프로젝트: sudevva/parser2
 public function __construct()
 {
     $this->registry = Registry::getInstance();
     $this->mailerConfig = $this->registry->config->getMailer();
     $this->message = \Swift_Message::newInstance();
     echo $this->mailerConfig->getSender() . PHP_EOL;
     $this->message->setFrom($this->mailerConfig->getSender());
     $this->transport = \Swift_SmtpTransport::newInstance($this->mailerConfig->getHost(), $this->mailerConfig->getPort(), 'ssl')->setUsername($this->mailerConfig->getUser())->setPassword($this->mailerConfig->getPass());
     parent::__construct($this->transport);
 }
예제 #6
0
 /**
  * Constructor
  *
  * @param \Swift_Mailer      $baseMailer
  * @param ContainerInterface $container
  */
 public function __construct(\Swift_Mailer $baseMailer, ContainerInterface $container)
 {
     $this->baseMailer = $baseMailer;
     $this->container = $container;
     $transport = $this->baseMailer->getTransport();
     if ($transport instanceof \Swift_Transport_SpoolTransport) {
         $transport = $this->findRealTransport();
         if (!$transport) {
             $transport = \Swift_NullTransport::newInstance();
         }
     }
     parent::__construct($transport);
 }
 public function __construct($config)
 {
     if (isset($config['spool_dir'])) {
         if (!file_exists($config['spool_dir'])) {
             mkdir($config['spool_dir']);
         }
         $spooler = new \Swift_FileSpool($config['spool_dir']);
         $spool_event_dispatcher = new \Swift_Events_SimpleEventDispatcher();
         $this->spool_transport = new \Swift_Transport_SpoolTransport($spool_event_dispatcher, $spooler);
     }
     $this->smtp_transport = \Swift_SmtpTransport::newInstance($config['host'], $config['port'])->setUsername($config['username'])->setPassword($config['password']);
     parent::__construct($this->spool_transport ? $this->spool_transport : $this->smtp_transport);
 }
 /**
  * When constructing, also initializes the Swift_Transport like configured
  *
  * @param Swift_Transport optionally pass a transport to the constructor. By default the configured transport from $TYPO3_CONF_VARS is used
  * @throws t3lib_exception
  */
 public function __construct(Swift_Transport $transport = NULL)
 {
     if ($transport !== NULL) {
         $this->transport = $transport;
     } else {
         try {
             $this->initializeTransport();
         } catch (Exception $e) {
             throw new t3lib_exception($e->getMessage(), 1291068569);
         }
     }
     parent::__construct($this->transport);
 }
예제 #9
0
 /**
  * When constructing, also initializes the \Swift_Transport like configured
  *
  * @param null|\Swift_Transport $transport optionally pass a transport to the constructor.
  * @throws \TYPO3\CMS\Core\Exception
  */
 public function __construct(\Swift_Transport $transport = NULL)
 {
     if ($transport !== NULL) {
         $this->transport = $transport;
     } else {
         if (empty($this->mailSettings)) {
             $this->injectMailSettings();
         }
         try {
             $this->initializeTransport();
         } catch (\Exception $e) {
             throw new \TYPO3\CMS\Core\Exception($e->getMessage(), 1291068569);
         }
     }
     parent::__construct($this->transport);
 }
예제 #10
0
 /**
  * Constructor
  *
  * @param \Swift_Mailer      $baseMailer
  * @param ContainerInterface $container
  */
 public function __construct(\Swift_Mailer $baseMailer, ContainerInterface $container, ImapEmailGoogleOauth2Manager $imapEmailGoogleOauth2Manager)
 {
     $this->baseMailer = $baseMailer;
     $this->container = $container;
     $this->imapEmailGoogleOauth2Manager = $imapEmailGoogleOauth2Manager;
     $transport = $this->baseMailer->getTransport();
     if ($transport instanceof \Swift_Transport_SpoolTransport) {
         $transport = $this->findRealTransport();
         if (!$transport) {
             $transport = \Swift_NullTransport::newInstance();
         }
     }
     if ($transport instanceof \Swift_Transport_EsmtpTransport) {
         $this->addXOAuth2Authenticator($transport);
     }
     parent::__construct($transport);
 }
예제 #11
0
 public function __construct(\Swift_Transport_EsmtpTransport $transport, ConfigManager $config, ContainerInterface $container)
 {
     $mandrillApiKey = $config->get('atwix_mandrill.api_key');
     $mandrillApiUsername = $config->get('atwix_mandrill.api_username');
     if ($config->get('atwix_mandrill.enable_mandrill_integration') && !empty($mandrillApiKey) && !empty($mandrillApiUsername)) {
         $handlers = $transport->getExtensionHandlers();
         /** @var \Swift_Transport_Esmtp_AuthHandler $handler */
         $handler = reset($handlers);
         $transport->setHost($config->get('atwix_mandrill.smtp_host'));
         $transport->setPort($config->get('atwix_mandrill.smtp_port'));
         $handler->setPassword($mandrillApiKey);
         $handler->setUsername($mandrillApiUsername);
         \Swift_Mailer::__construct($transport);
     } else {
         $mailer = $container->get('mailer');
         parent::__construct($mailer, $container);
     }
 }
예제 #12
0
 /**
  * Constructor.
  *
  * Available options:
  *
  *  * charset: The default charset to use for messages
  *  * logging: Whether to enable logging or not
  *  * delivery_strategy: The delivery strategy to use
  *  * spool_class: The spool class (for the spool strategy)
  *  * spool_arguments: The arguments to pass to the spool constructor
  *  * delivery_address: The email address to use for the single_address strategy
  *  * transport: The main transport configuration
  *  *   * class: The main transport class
  *  *   * param: The main transport parameters
  *
  * @param sfEventDispatcher $dispatcher An event dispatcher instance
  * @param array             $options    An array of options
  */
 public function __construct(sfEventDispatcher $dispatcher, $options)
 {
     // options
     $options = array_merge(array('charset' => 'UTF-8', 'logging' => false, 'delivery_strategy' => 'realtime', 'transport' => array('class' => 'Swift_MailTransport', 'param' => array())), $options);
     $constantName = 'sfMailer::' . strtoupper($options['delivery_strategy']);
     $this->strategy = defined($constantName) ? constant($constantName) : false;
     if (!$this->strategy) {
         throw new InvalidArgumentException(sprintf('Unknown mail delivery strategy "%s" (should be one of realtime, spool, single_address, or none)', $options['delivery_strategy']));
     }
     // transport
     $class = $options['transport']['class'];
     $transport = new $class();
     if (isset($options['transport']['param'])) {
         foreach ($options['transport']['param'] as $key => $value) {
             $method = 'set' . ucfirst($key);
             if (method_exists($transport, $method)) {
                 $transport->{$method}($value);
             } elseif (method_exists($transport, 'getExtensionHandlers')) {
                 foreach ($transport->getExtensionHandlers() as $handler) {
                     if (in_array(strtolower($method), array_map('strtolower', (array) $handler->exposeMixinMethods()))) {
                         $transport->{$method}($value);
                     }
                 }
             }
         }
     }
     $this->realtimeTransport = $transport;
     if (sfMailer::SPOOL == $this->strategy) {
         if (!isset($options['spool_class'])) {
             throw new InvalidArgumentException('For the spool mail delivery strategy, you must also define a spool_class option');
         }
         $arguments = isset($options['spool_arguments']) ? $options['spool_arguments'] : array();
         if ($arguments) {
             $r = new ReflectionClass($options['spool_class']);
             $this->spool = $r->newInstanceArgs($arguments);
         } else {
             $this->spool = new $options['spool_class']();
         }
         $transport = new Swift_SpoolTransport($this->spool);
     } elseif (sfMailer::SINGLE_ADDRESS == $this->strategy) {
         if (!isset($options['delivery_address'])) {
             throw new InvalidArgumentException('For the single_address mail delivery strategy, you must also define a delivery_address option');
         }
         $this->address = $options['delivery_address'];
         $transport->registerPlugin($this->redirectingPlugin = new Swift_Plugins_RedirectingPlugin($this->address));
     }
     parent::__construct($transport);
     // logger
     if ($options['logging']) {
         $this->logger = new sfMailerMessageLoggerPlugin($dispatcher);
         $transport->registerPlugin($this->logger);
     }
     if (sfMailer::NONE == $this->strategy) {
         // must be registered after logging
         $transport->registerPlugin(new Swift_Plugins_BlackholePlugin());
     }
     // preferences
     Swift_Preferences::getInstance()->setCharset($options['charset']);
     $dispatcher->notify(new sfEvent($this, 'mailer.configure'));
 }