getInstance() public static méthode

Returns a singleton of the DependencyContainer.
public static getInstance ( ) : Swift_DependencyContainer
Résultat Swift_DependencyContainer
 /**
  * Checks if an email matches the current grammars
  * @param string $email
  */
 public static function email($email)
 {
     if (self::$grammar === null) {
         self::$grammar = Swift_DependencyContainer::getInstance()->lookup('mime.grammar');
     }
     return preg_match('/^' . self::$grammar->getDefinition('addr-spec') . '$/D', $email);
 }
 /**
  * Create a new SmtpTransport, optionally with $host, $port and $security.
  *
  * @param string  $host
  * @param integer $port
  * @param string  $security
  */
 public function __construct($host = 'localhost', $port = 25, $security = null)
 {
     call_user_func_array(array($this, 'Swift_Transport_EsmtpTransport::__construct'), Swift_DependencyContainer::getInstance()->createDependenciesFor('transport.smtp'));
     $this->setHost($host);
     $this->setPort($port);
     $this->setEncryption($security);
 }
 /**
  * Create a new NullTransport.
  */
 public function __construct()
 {
   call_user_func_array(
     array($this, 'Swift_Transport_NullTransport::__construct'),
     Swift_DependencyContainer::getInstance()
       ->createDependenciesFor('transport.null')
   );
 }
Exemple #4
0
 /**
  * Create a new AWSTransport.
  * @param string $AWSAccessKeyId Your access key.
  * @param string $AWSSecretKey Your secret key.
  * @param boolean $debug Set to true to enable debug messages in error log.
  * @param string $endpoint The AWS endpoint to use.
  */
 public function __construct($AWSAccessKeyId = null, $AWSSecretKey = null, $debug = false, $endpoint = 'https://email.us-east-1.amazonaws.com/')
 {
     call_user_func_array(array($this, 'Swift_Transport_AWSTransport::__construct'), Swift_DependencyContainer::getInstance()->createDependenciesFor('transport.aws'));
     $this->AWSAccessKeyId = $AWSAccessKeyId;
     $this->AWSSecretKey = $AWSSecretKey;
     $this->endpoint = $endpoint;
     $this->debug = $debug;
 }
Exemple #5
0
 /**
  * Create a new EmbeddedFile.
  * Details may be optionally provided to the constructor.
  * @param string|Swift_OutputByteStream $data
  * @param string                        $filename
  * @param string                        $contentType
  */
 public function __construct($data = NULL, $filename = NULL, $contentType = NULL)
 {
     call_user_func_array(array($this, 'Swift_Mime_EmbeddedFile::__construct'), Swift_DependencyContainer::getInstance()->createDependenciesFor('mime.embeddedfile'));
     $this->setBody($data);
     $this->setFilename($filename);
     if ($contentType) {
         $this->setContentType($contentType);
     }
 }
 /**
  * Create a new Attachment.
  *
  * Details may be optionally provided to the constructor.
  *
  * @param string|Swift_OutputByteStream $data
  * @param string                        $filename
  * @param string                        $contentType
  */
 public function __construct($data = null, $filename = null, $contentType = null)
 {
     call_user_func_array(array($this, 'Swift_Mime_Attachment::__construct'), Swift_DependencyContainer::getInstance()->createDependenciesFor('mime.attachment'));
     $this->setBody($data);
     $this->setFilename($filename);
     if ($contentType) {
         $this->setContentType($contentType);
     }
 }
  /**
   * Create a new SendmailTransport, optionally using $command for sending.
   * @param string $command
   */
  public function __construct($command = '/usr/sbin/sendmail -bs')
  {
    call_user_func_array(
      array($this, 'Swift_Transport_SendmailTransport::__construct'),
      Swift_DependencyContainer::getInstance()
        ->createDependenciesFor('transport.sendmail')
      );

    $this->setCommand($command);
  }
  /**
   * Create a new MailTransport, optionally specifying $extraParams.
   * @param string $extraParams
   */
  public function __construct($extraParams = '-f%s')
  {
    call_user_func_array(
      array($this, 'Swift_Transport_MailTransport::__construct'),
      Swift_DependencyContainer::getInstance()
        ->createDependenciesFor('transport.mail')
      );

    $this->setExtraParams($extraParams);
  }
  /**
   * Creates a new FailoverTransport with $transports.
   * @param array $transports
   */
  public function __construct($transports = array())
  {
    call_user_func_array(
      array($this, 'Swift_Transport_FailoverTransport::__construct'),
      Swift_DependencyContainer::getInstance()
        ->createDependenciesFor('transport.failover')
      );

    $this->setTransports($transports);
  }
 public function testNoLookupsFail()
 {
     $di = Swift_DependencyContainer::getInstance();
     foreach ($di->listItems() as $itemName) {
         try {
             $di->lookup($itemName);
         } catch (Swift_DependencyException $e) {
             $this->fail($e->getMessage());
         }
     }
 }
Exemple #11
0
 /**
  * Create a new MimePart.
  *
  * Details may be optionally passed into the constructor.
  *
  * @param string $body        	
  * @param string $contentType        	
  * @param string $charset        	
  */
 public function __construct($body = null, $contentType = null, $charset = null)
 {
     call_user_func_array(array($this, 'Swift_Mime_MimePart::__construct'), Swift_DependencyContainer::getInstance()->createDependenciesFor('mime.part'));
     if (!isset($charset)) {
         $charset = Swift_DependencyContainer::getInstance()->lookup('properties.charset');
     }
     $this->setBody($body);
     $this->setCharset($charset);
     if ($contentType) {
         $this->setContentType($contentType);
     }
 }
  /**
   * Create a new SpoolTransport.
   * @param Swift_Spool $spool
   */
  public function __construct(Swift_Spool $spool)
  {
    $arguments = Swift_DependencyContainer::getInstance()
      ->createDependenciesFor('transport.spool');

    $arguments[] = $spool;

    call_user_func_array(
      array($this, 'Swift_Transport_SpoolTransport::__construct'),
      $arguments
    );
  }
Exemple #13
0
 /**
  * Create a new Message.
  * Details may be optionally passed into the constructor.
  * @param string $subject
  * @param string $body
  * @param string $contentType
  * @param string $charset
  */
 public function __construct($subject = NULL, $body = NULL, $contentType = NULL, $charset = NULL)
 {
     call_user_func_array(array($this, 'Swift_Mime_SimpleMessage::__construct'), Swift_DependencyContainer::getInstance()->createDependenciesFor('mime.message'));
     if (!isset($charset)) {
         $charset = Swift_DependencyContainer::getInstance()->lookup('properties.charset');
     }
     $this->setSubject($subject);
     $this->setBody($body);
     $this->setCharset($charset);
     if ($contentType) {
         $this->setContentType($contentType);
     }
 }
 /**
  * Swift初期化
  *
  * @param String $host
  * @param String $port
  * @param String $user
  * @param String $pass
  * @param String $charset
  * @return vold
  * @codeCoverageIgnore
  */
 public function __construct($host, $port, $user, $pass, $charset = 'iso-2022-jp')
 {
     $this->host = $host;
     $this->port = $port;
     $this->user = $user;
     $this->pass = $pass;
     $this->charset = $charset;
     $this->setPath();
     \Swift::init(function () use($charset) {
         \Swift_DependencyContainer::getInstance()->register('mime.qpheaderencoder')->asAliasOf('mime.base64headerencoder');
         \Swift_Preferences::getInstance()->setCharset($charset);
     });
 }
 /**
  * Выполняется перед каждым запросом браузера
  *
  * @return void
  */
 public function prepare()
 {
     // Инициализировать директории
     $this->_mailDir = $this->_initDir('app_mail_save_dir');
     $this->_templateDir = $this->_initDir('app_mail_template_dir', $create = false);
     // Очистить директорию с письмами
     $this->reset();
     // Обработчик писем
     $this->_invoker = new myMailInvokerSave($this->_mailDir);
     Swift_DependencyContainer::getInstance()->register('transport.mailinvoker')->asValue($this->_invoker);
     // Указать ошибочные email
     if ($this->_errors) {
         $this->_invoker->setErrors($this->_errors);
         $this->_errors = null;
     }
 }
Exemple #16
0
 protected function _getMailer()
 {
     switch (SWIFT_SMOKE_TRANSPORT_TYPE) {
         case 'smtp':
             $transport = Swift_DependencyContainer::getInstance()->lookup('transport.smtp')->setHost(SWIFT_SMOKE_SMTP_HOST)->setPort(SWIFT_SMOKE_SMTP_PORT)->setUsername(SWIFT_SMOKE_SMTP_USER)->setPassword(SWIFT_SMOKE_SMTP_PASS)->setEncryption(SWIFT_SMOKE_SMTP_ENCRYPTION);
             break;
         case 'sendmail':
             $transport = Swift_DependencyContainer::getInstance()->lookup('transport.sendmail')->setCommand(SWIFT_SMOKE_SENDMAIL_COMMAND);
             break;
         case 'mail':
         case 'nativemail':
             $transport = Swift_DependencyContainer::getInstance()->lookup('transport.mail');
             break;
         default:
             throw new Exception('Undefined transport [' . SWIFT_SMOKE_TRANSPORT_TYPE . ']');
     }
     return new Swift_Mailer($transport);
 }
 public function __wakeup()
 {
     Swift_DependencyContainer::getInstance()->createDependenciesFor('mime.message');
 }
Exemple #18
0
 /**
  * Create a new class instance of one of the message services.
  *
  * For example 'mimepart' would create a 'message.mimepart' instance
  *
  * @param string $service
  *
  * @return object
  */
 public function createMessage($service = 'message')
 {
     return Swift_DependencyContainer::getInstance()->lookup('message.' . $service);
 }
<?php

Swift_DependencyContainer::getInstance()->register('transport.smtp')->asNewInstanceOf('Swift_Transport_EsmtpTransport')->withDependencies(array('transport.buffer', array('transport.authhandler'), 'transport.eventdispatcher'))->register('transport.sendmail')->asNewInstanceOf('Swift_Transport_SendmailTransport')->withDependencies(array('transport.buffer', 'transport.eventdispatcher'))->register('transport.mail')->asNewInstanceOf('Swift_Transport_MailTransport')->withDependencies(array('transport.mailinvoker', 'transport.eventdispatcher'))->register('transport.loadbalanced')->asNewInstanceOf('Swift_Transport_LoadBalancedTransport')->register('transport.failover')->asNewInstanceOf('Swift_Transport_FailoverTransport')->register('transport.spool')->asNewInstanceOf('Swift_Transport_SpoolTransport')->withDependencies(array('transport.eventdispatcher'))->register('transport.null')->asNewInstanceOf('Swift_Transport_NullTransport')->withDependencies(array('transport.eventdispatcher'))->register('transport.mailinvoker')->asSharedInstanceOf('Swift_Transport_SimpleMailInvoker')->register('transport.buffer')->asNewInstanceOf('Swift_Transport_StreamBuffer')->withDependencies(array('transport.replacementfactory'))->register('transport.authhandler')->asNewInstanceOf('Swift_Transport_Esmtp_AuthHandler')->withDependencies(array(array('transport.crammd5auth', 'transport.loginauth', 'transport.plainauth', 'transport.ntlmauth', 'transport.xoauth2auth')))->register('transport.crammd5auth')->asNewInstanceOf('Swift_Transport_Esmtp_Auth_CramMd5Authenticator')->register('transport.loginauth')->asNewInstanceOf('Swift_Transport_Esmtp_Auth_LoginAuthenticator')->register('transport.plainauth')->asNewInstanceOf('Swift_Transport_Esmtp_Auth_PlainAuthenticator')->register('transport.xoauth2auth')->asNewInstanceOf('Swift_Transport_Esmtp_Auth_XOAuth2Authenticator')->register('transport.ntlmauth')->asNewInstanceOf('Swift_Transport_Esmtp_Auth_NTLMAuthenticator')->register('transport.eventdispatcher')->asNewInstanceOf('Swift_Events_SimpleEventDispatcher')->register('transport.replacementfactory')->asSharedInstanceOf('Swift_StreamFilters_StringReplacementFilterFactory');
Exemple #20
0
 /**
  * Set the QuotedPrintable dot escaper preference.
  *
  * @param bool $dotEscape
  *
  * @return Swift_Preferences
  */
 public function setQPDotEscape($dotEscape)
 {
     $dotEscape = !empty($dotEscape);
     Swift_DependencyContainer::getInstance()->register('mime.qpcontentencoder')->asNewInstanceOf('Swift_Mime_ContentEncoder_QpContentEncoder')->withDependencies(array('mime.charstream', 'mime.bytecanonicalizer'))->addConstructorValue($dotEscape);
     return $this;
 }
 private function _createEncoderFromContainer()
 {
     return Swift_DependencyContainer::getInstance()->lookup('mime.nativeqpcontentencoder');
 }
<?php

Swift_DependencyContainer::getInstance()
  
  -> register('transport.smtp')
  -> asNewInstanceOf('Swift_Transport_EsmtpTransport')
  -> withDependencies(array(
    'transport.buffer',
    array('transport.authhandler'),
    'transport.eventdispatcher'
  ))
  
  -> register('transport.sendmail')
  -> asNewInstanceOf('Swift_Transport_SendmailTransport')
  -> withDependencies(array(
    'transport.buffer',
    'transport.eventdispatcher'
  ))
  
  -> register('transport.mail')
  -> asNewInstanceOf('Swift_Transport_MailTransport')
  -> withDependencies(array('transport.mailinvoker', 'transport.eventdispatcher'))
  
  -> register('transport.loadbalanced')
  -> asNewInstanceOf('Swift_Transport_LoadBalancedTransport')
  
  -> register('transport.failover')
  -> asNewInstanceOf('Swift_Transport_FailoverTransport')
  
  -> register('transport.mailinvoker')
  -> asSharedInstanceOf('Swift_Transport_SimpleMailInvoker')
 private static function _lookup($key)
 {
     return Swift_DependencyContainer::getInstance()->lookup($key);
 }
 /**
  * Merges an OutputByteStream to Swift_Message.
  *
  * @param Swift_OutputByteStream $fromStream
  * @param Swift_Message          $message
  */
 protected function streamToMime(Swift_OutputByteStream $fromStream, Swift_Message $message)
 {
     $bufferLength = 78;
     $headerData = '';
     $fromStream->setReadPointer(0);
     while (($buffer = $fromStream->read($bufferLength)) !== false) {
         $headerData .= $buffer;
         if (false !== strpos($buffer, "\r\n\r\n")) {
             break;
         }
     }
     $headersPosEnd = strpos($headerData, "\r\n\r\n");
     $headerData = trim($headerData);
     $headerData = substr($headerData, 0, $headersPosEnd);
     $headerLines = explode("\r\n", $headerData);
     unset($headerData);
     $headers = array();
     $currentHeaderName = '';
     foreach ($headerLines as $headerLine) {
         // Line separated
         if (ctype_space($headerLines[0]) || false === strpos($headerLine, ':')) {
             $headers[$currentHeaderName] .= ' ' . trim($headerLine);
             continue;
         }
         $header = explode(':', $headerLine, 2);
         $currentHeaderName = strtolower($header[0]);
         $headers[$currentHeaderName] = trim($header[1]);
     }
     $messageStream = new Swift_ByteStream_TemporaryFileByteStream();
     $messageStream->addFilter($this->replacementFactory->createFilter("\r\n", "\n"), 'CRLF to LF');
     $messageStream->addFilter($this->replacementFactory->createFilter("\n", "\r\n"), 'LF to CRLF');
     $messageHeaders = $message->getHeaders();
     // No need to check for 'application/pkcs7-mime', as this is always base64
     if ('multipart/signed;' === substr($headers['content-type'], 0, 17)) {
         if (!preg_match('/boundary=("[^"]+"|(?:[^\\s]+|$))/is', $headers['content-type'], $contentTypeData)) {
             throw new Swift_SwiftException('Failed to find Boundary parameter');
         }
         $boundary = trim($contentTypeData['1'], '"');
         $boundaryLen = strlen($boundary);
         // Skip the header and CRLF CRLF
         $fromStream->setReadPointer($headersPosEnd + 4);
         while (false !== ($buffer = $fromStream->read($bufferLength))) {
             $messageStream->write($buffer);
         }
         $messageStream->commit();
         $messageHeaders->remove('Content-Transfer-Encoding');
         $message->setContentType($headers['content-type']);
         $message->setBoundary($boundary);
         $message->setBody($messageStream);
     } else {
         $fromStream->setReadPointer($headersPosEnd + 4);
         if (null === $this->headerFactory) {
             $this->headerFactory = Swift_DependencyContainer::getInstance()->lookup('mime.headerfactory');
         }
         $message->setContentType($headers['content-type']);
         $messageHeaders->set($this->headerFactory->createTextHeader('Content-Transfer-Encoding', $headers['content-transfer-encoding']));
         $messageHeaders->set($this->headerFactory->createTextHeader('Content-Disposition', $headers['content-disposition']));
         while (false !== ($buffer = $fromStream->read($bufferLength))) {
             $messageStream->write($buffer);
         }
         $messageStream->commit();
         $message->setBody($messageStream);
     }
 }
 /**
  *
  * @param array $headersRaw
  * @return \Swift_Mime_HeaderSet
  */
 protected function createHeadersSet(array $headersRaw)
 {
     $headers = \Swift_DependencyContainer::getInstance()->lookup('mime.headerset');
     foreach ($headersRaw as $name => $value) {
         switch (strtolower($name)) {
             case "content-type":
                 $parts = $this->extractHeaderParts($value);
                 unset($parts["boundary"]);
                 $headers->addParameterizedHeader($name, $this->extractValueHeader($value), $parts);
                 break;
             case "return-path":
                 if (preg_match_all('/([a-z][a-z0-9_\\-\\.]*@[a-z0-9\\.\\-]*\\.[a-z]{2,5})/i', $value, $mch)) {
                     foreach ($mch[0] as $k => $mails) {
                         $headers->addPathHeader($name, $mch[1][$k]);
                     }
                 }
                 break;
             case "date":
                 $headers->addDateHeader($name, strtotime($value));
             case "to":
             case "from":
             case "bcc":
             case "reply-to":
             case "cc":
                 $adresses = array();
                 if (preg_match_all('/(.*?)<([a-z][a-z0-9_\\-\\.]*@[a-z0-9\\.\\-]*\\.[a-z]{2,5})>\\s*[;,]*/i', $value, $mch)) {
                     foreach ($mch[0] as $k => $mail) {
                         if (!$mch[1][$k]) {
                             $adresses[$mch[2][$k]] = $mch[2][$k];
                         } else {
                             $adresses[$mch[2][$k]] = $mch[1][$k];
                         }
                     }
                 } elseif (preg_match_all('/([a-z][a-z0-9_\\-\\.]*@[a-z0-9\\.\\-]*\\.[a-z]{2,5})/i', $value, $mch)) {
                     foreach ($mch[0] as $k => $mails) {
                         $adresses[$mch[1][$k]] = $mch[1][$k];
                     }
                 }
                 $headers->addMailboxHeader($name, $adresses);
                 break;
             default:
                 $headers->addTextHeader($name, $value);
                 break;
         }
     }
     return $headers;
 }
Exemple #26
0
<?php

require dirname(__FILE__) . '/../mime_types.php';
Swift_DependencyContainer::getInstance()->register('properties.charset')->asValue('utf-8')->register('mime.grammar')->asSharedInstanceOf('Swift_Mime_Grammar')->register('mime.message')->asNewInstanceOf('Swift_Mime_SimpleMessage')->withDependencies(array('mime.headerset', 'mime.qpcontentencoder', 'cache', 'mime.grammar', 'properties.charset'))->register('mime.part')->asNewInstanceOf('Swift_Mime_MimePart')->withDependencies(array('mime.headerset', 'mime.qpcontentencoder', 'cache', 'mime.grammar', 'properties.charset'))->register('mime.attachment')->asNewInstanceOf('Swift_Mime_Attachment')->withDependencies(array('mime.headerset', 'mime.base64contentencoder', 'cache', 'mime.grammar'))->addConstructorValue($swift_mime_types)->register('mime.embeddedfile')->asNewInstanceOf('Swift_Mime_EmbeddedFile')->withDependencies(array('mime.headerset', 'mime.base64contentencoder', 'cache', 'mime.grammar'))->addConstructorValue($swift_mime_types)->register('mime.headerfactory')->asNewInstanceOf('Swift_Mime_SimpleHeaderFactory')->withDependencies(array('mime.qpheaderencoder', 'mime.rfc2231encoder', 'mime.grammar', 'properties.charset'))->register('mime.headerset')->asNewInstanceOf('Swift_Mime_SimpleHeaderSet')->withDependencies(array('mime.headerfactory', 'properties.charset'))->register('mime.qpheaderencoder')->asNewInstanceOf('Swift_Mime_HeaderEncoder_QpHeaderEncoder')->withDependencies(array('mime.charstream'))->register('mime.base64headerencoder')->asNewInstanceOf('Swift_Mime_HeaderEncoder_Base64HeaderEncoder')->withDependencies(array('mime.charstream'))->register('mime.charstream')->asNewInstanceOf('Swift_CharacterStream_NgCharacterStream')->withDependencies(array('mime.characterreaderfactory', 'properties.charset'))->register('mime.bytecanonicalizer')->asSharedInstanceOf('Swift_StreamFilters_ByteArrayReplacementFilter')->addConstructorValue(array(array(0xd, 0xa), array(0xd), array(0xa)))->addConstructorValue(array(array(0xa), array(0xa), array(0xd, 0xa)))->register('mime.characterreaderfactory')->asSharedInstanceOf('Swift_CharacterReaderFactory_SimpleCharacterReaderFactory')->register('mime.safeqpcontentencoder')->asNewInstanceOf('Swift_Mime_ContentEncoder_QpContentEncoder')->withDependencies(array('mime.charstream', 'mime.bytecanonicalizer'))->register('mime.rawcontentencoder')->asNewInstanceOf('Swift_Mime_ContentEncoder_RawContentEncoder')->register('mime.nativeqpcontentencoder')->withDependencies(array('properties.charset'))->asNewInstanceOf('Swift_Mime_ContentEncoder_NativeQpContentEncoder')->register('mime.qpcontentencoderproxy')->asNewInstanceOf('Swift_Mime_ContentEncoder_QpContentEncoderProxy')->withDependencies(array('mime.safeqpcontentencoder', 'mime.nativeqpcontentencoder', 'properties.charset'))->register('mime.7bitcontentencoder')->asNewInstanceOf('Swift_Mime_ContentEncoder_PlainContentEncoder')->addConstructorValue('7bit')->addConstructorValue(true)->register('mime.8bitcontentencoder')->asNewInstanceOf('Swift_Mime_ContentEncoder_PlainContentEncoder')->addConstructorValue('8bit')->addConstructorValue(true)->register('mime.base64contentencoder')->asSharedInstanceOf('Swift_Mime_ContentEncoder_Base64ContentEncoder')->register('mime.rfc2231encoder')->asNewInstanceOf('Swift_Encoder_Rfc2231Encoder')->withDependencies(array('mime.charstream'))->register('mime.qpcontentencoder')->asAliasOf(version_compare(phpversion(), '5.4.7', '>=') ? 'mime.qpcontentencoderproxy' : 'mime.safeqpcontentencoder');
unset($swift_mime_types);
 protected function _createMessage()
 {
     Swift_DependencyContainer::getInstance()->register('properties.charset')->asValue(null);
     return Swift_Message::newInstance();
 }
Exemple #28
0
<?php

require dirname(__FILE__) . '/../mime_types.php';
Swift_DependencyContainer::getInstance()->register('properties.charset')->asValue('utf-8')->register('mime.grammar')->asSharedInstanceOf('Swift_Mime_Grammar')->register('mime.message')->asNewInstanceOf('Swift_Mime_SimpleMessage')->withDependencies(array('mime.headerset', 'mime.qpcontentencoder', 'cache', 'mime.grammar', 'properties.charset'))->register('mime.part')->asNewInstanceOf('Swift_Mime_MimePart')->withDependencies(array('mime.headerset', 'mime.qpcontentencoder', 'cache', 'mime.grammar', 'properties.charset'))->register('mime.attachment')->asNewInstanceOf('Swift_Mime_Attachment')->withDependencies(array('mime.headerset', 'mime.base64contentencoder', 'cache', 'mime.grammar'))->addConstructorValue($swift_mime_types)->register('mime.embeddedfile')->asNewInstanceOf('Swift_Mime_EmbeddedFile')->withDependencies(array('mime.headerset', 'mime.base64contentencoder', 'cache', 'mime.grammar'))->addConstructorValue($swift_mime_types)->register('mime.headerfactory')->asNewInstanceOf('Swift_Mime_SimpleHeaderFactory')->withDependencies(array('mime.qpheaderencoder', 'mime.rfc2231encoder', 'mime.grammar', 'properties.charset'))->register('mime.headerset')->asNewInstanceOf('Swift_Mime_SimpleHeaderSet')->withDependencies(array('mime.headerfactory', 'properties.charset'))->register('mime.qpheaderencoder')->asNewInstanceOf('Swift_Mime_HeaderEncoder_QpHeaderEncoder')->withDependencies(array('mime.charstream'))->register('mime.base64headerencoder')->asNewInstanceOf('Swift_Mime_HeaderEncoder_Base64HeaderEncoder')->withDependencies(array('mime.charstream'))->register('mime.charstream')->asNewInstanceOf('Swift_CharacterStream_NgCharacterStream')->withDependencies(array('mime.characterreaderfactory', 'properties.charset'))->register('mime.bytecanonicalizer')->asSharedInstanceOf('Swift_StreamFilters_ByteArrayReplacementFilter')->addConstructorValue(array(array(0xd, 0xa), array(0xd), array(0xa)))->addConstructorValue(array(array(0xa), array(0xa), array(0xd, 0xa)))->register('mime.characterreaderfactory')->asSharedInstanceOf('Swift_CharacterReaderFactory_SimpleCharacterReaderFactory')->register('mime.qpcontentencoder')->asNewInstanceOf('Swift_Mime_ContentEncoder_QpContentEncoder')->withDependencies(array('mime.charstream', 'mime.bytecanonicalizer'))->register('mime.nativeqpcontentencoder')->asNewInstanceOf('Swift_Mime_ContentEncoder_NativeQpContentEncoder')->register('mime.7bitcontentencoder')->asNewInstanceOf('Swift_Mime_ContentEncoder_PlainContentEncoder')->addConstructorValue('7bit')->addConstructorValue(true)->register('mime.8bitcontentencoder')->asNewInstanceOf('Swift_Mime_ContentEncoder_PlainContentEncoder')->addConstructorValue('8bit')->addConstructorValue(true)->register('mime.base64contentencoder')->asSharedInstanceOf('Swift_Mime_ContentEncoder_Base64ContentEncoder')->register('mime.rfc2231encoder')->asNewInstanceOf('Swift_Encoder_Rfc2231Encoder')->withDependencies(array('mime.charstream'));
// As of PHP 5.4.7, the quoted_printable_encode() function behaves correctly.
// see https://github.com/php/php-src/commit/18bb426587d62f93c54c40bf8535eb8416603629
if (version_compare(phpversion(), '5.4.7', '>=')) {
    Swift_DependencyContainer::getInstance()->register('mime.qpcontentencoder')->asAliasOf('mime.nativeqpcontentencoder');
}
unset($swift_mime_types);
Exemple #29
0
<?php

require __DIR__ . '/../mime_types.php';
Swift_DependencyContainer::getInstance()->register('properties.charset')->asValue('utf-8')->register('email.validator')->asSharedInstanceOf('Egulias\\EmailValidator\\EmailValidator')->register('mime.idgenerator.idright')->asValue(!empty($_SERVER['SERVER_NAME']) && preg_replace('/(?:^\\[)?[a-zA-Z0-9-:\\]_]+\\.?/', '', $_SERVER['SERVER_NAME']) === '' ? $_SERVER['SERVER_NAME'] : 'swift.generated')->register('mime.idgenerator')->asSharedInstanceOf('Swift_Mime_IdGenerator')->withDependencies(array('mime.idgenerator.idright'))->register('mime.message')->asNewInstanceOf('Swift_Mime_SimpleMessage')->withDependencies(array('mime.headerset', 'mime.qpcontentencoder', 'cache', 'mime.idgenerator', 'properties.charset'))->register('mime.part')->asNewInstanceOf('Swift_Mime_MimePart')->withDependencies(array('mime.headerset', 'mime.qpcontentencoder', 'cache', 'mime.idgenerator', 'properties.charset'))->register('mime.attachment')->asNewInstanceOf('Swift_Mime_Attachment')->withDependencies(array('mime.headerset', 'mime.base64contentencoder', 'cache', 'mime.idgenerator'))->addConstructorValue($swift_mime_types)->register('mime.embeddedfile')->asNewInstanceOf('Swift_Mime_EmbeddedFile')->withDependencies(array('mime.headerset', 'mime.base64contentencoder', 'cache', 'mime.idgenerator'))->addConstructorValue($swift_mime_types)->register('mime.headerfactory')->asNewInstanceOf('Swift_Mime_SimpleHeaderFactory')->withDependencies(array('mime.qpheaderencoder', 'mime.rfc2231encoder', 'email.validator', 'properties.charset'))->register('mime.headerset')->asNewInstanceOf('Swift_Mime_SimpleHeaderSet')->withDependencies(array('mime.headerfactory', 'properties.charset'))->register('mime.qpheaderencoder')->asNewInstanceOf('Swift_Mime_HeaderEncoder_QpHeaderEncoder')->withDependencies(array('mime.charstream'))->register('mime.base64headerencoder')->asNewInstanceOf('Swift_Mime_HeaderEncoder_Base64HeaderEncoder')->withDependencies(array('mime.charstream'))->register('mime.charstream')->asNewInstanceOf('Swift_CharacterStream_NgCharacterStream')->withDependencies(array('mime.characterreaderfactory', 'properties.charset'))->register('mime.bytecanonicalizer')->asSharedInstanceOf('Swift_StreamFilters_ByteArrayReplacementFilter')->addConstructorValue(array(array(0xd, 0xa), array(0xd), array(0xa)))->addConstructorValue(array(array(0xa), array(0xa), array(0xd, 0xa)))->register('mime.characterreaderfactory')->asSharedInstanceOf('Swift_CharacterReaderFactory_SimpleCharacterReaderFactory')->register('mime.safeqpcontentencoder')->asNewInstanceOf('Swift_Mime_ContentEncoder_QpContentEncoder')->withDependencies(array('mime.charstream', 'mime.bytecanonicalizer'))->register('mime.rawcontentencoder')->asNewInstanceOf('Swift_Mime_ContentEncoder_RawContentEncoder')->register('mime.nativeqpcontentencoder')->withDependencies(array('properties.charset'))->asNewInstanceOf('Swift_Mime_ContentEncoder_NativeQpContentEncoder')->register('mime.qpcontentencoder')->asNewInstanceOf('Swift_Mime_ContentEncoder_QpContentEncoderProxy')->withDependencies(array('mime.safeqpcontentencoder', 'mime.nativeqpcontentencoder', 'properties.charset'))->register('mime.7bitcontentencoder')->asNewInstanceOf('Swift_Mime_ContentEncoder_PlainContentEncoder')->addConstructorValue('7bit')->addConstructorValue(true)->register('mime.8bitcontentencoder')->asNewInstanceOf('Swift_Mime_ContentEncoder_PlainContentEncoder')->addConstructorValue('8bit')->addConstructorValue(true)->register('mime.base64contentencoder')->asSharedInstanceOf('Swift_Mime_ContentEncoder_Base64ContentEncoder')->register('mime.rfc2231encoder')->asNewInstanceOf('Swift_Encoder_Rfc2231Encoder')->withDependencies(array('mime.charstream'));
unset($swift_mime_types);
Exemple #30
0
 public function initMailer()
 {
     // メール送信時の文字エンコード指定(デフォルトはUTF-8)
     if (isset($this['config']['mail']['charset_iso_2022_jp']) && is_bool($this['config']['mail']['charset_iso_2022_jp'])) {
         if ($this['config']['mail']['charset_iso_2022_jp'] === true) {
             \Swift::init(function () {
                 \Swift_DependencyContainer::getInstance()->register('mime.qpheaderencoder')->asAliasOf('mime.base64headerencoder');
                 \Swift_Preferences::getInstance()->setCharset('iso-2022-jp');
             });
         }
     }
     $this->register(new \Silex\Provider\SwiftmailerServiceProvider());
     $this['swiftmailer.options'] = $this['config']['mail'];
     if (isset($this['config']['mail']['spool']) && is_bool($this['config']['mail']['spool'])) {
         $this['swiftmailer.use_spool'] = $this['config']['mail']['spool'];
     }
     // デフォルトはsmtpを使用
     $transport = $this['config']['mail']['transport'];
     if ($transport == 'sendmail') {
         $this['swiftmailer.transport'] = \Swift_SendmailTransport::newInstance();
     } elseif ($transport == 'mail') {
         $this['swiftmailer.transport'] = \Swift_MailTransport::newInstance();
     }
 }