当前位置: 首页>>代码示例>>PHP>>正文


PHP Swift::connect方法代码示例

本文整理汇总了PHP中Swift::connect方法的典型用法代码示例。如果您正苦于以下问题:PHP Swift::connect方法的具体用法?PHP Swift::connect怎么用?PHP Swift::connect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Swift的用法示例。


在下文中一共展示了Swift::connect方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: isAuthenticated

 /**
  * Try to authenticate using the username and password
  * Returns false on failure
  * @param string The username
  * @param string The password
  * @param Swift The instance of Swift this authenticator is used in
  * @return boolean
  */
 public function isAuthenticated($user, $pass, Swift $swift)
 {
   $log = Swift_LogContainer::getLog();
   if ($log->hasLevel(Swift_Log::LOG_EVERYTHING))
   {
     $log->add("Trying POP3 Before SMTP authentication.  Disconnecting from SMTP first.");
   }
   $swift->disconnect();
   try {
     $this->connection->start();
     $this->connection->assertOk($this->connection->read());
     $this->connection->write("USER " . $user);
     $this->connection->assertOk($this->connection->read());
     $this->connection->write("PASS " . $pass);
     $this->connection->assertOk($this->connection->read());
     $this->connection->write("QUIT");
     $this->connection->assertOk($this->connection->read());
     $this->connection->stop();
   } catch (Swift_ConnectionException $e) {
     if ($log->hasLevel(Swift_Log::LOG_ERRORS))
     {
       $log->add($e->getMessage(),Swift_Log::ERROR);
       $log->add("POP3 authentication failed.");
     }
     return false;
   }
   $options = $swift->getOptions();
   $swift->setOptions($options | Swift::NO_POST_CONNECT);
   $swift->connect();
   $swift->setOptions($options);
   return true;
 }
开发者ID:neutrinog,项目名称:Door43,代码行数:40,代码来源:PopB4Smtp.php

示例2: forceRestartSwift

 /**
  * Restarts Swift forcibly.
  */
 protected function forceRestartSwift()
 {
     //Pre-empting problems trying to issue "QUIT" to a dead connection
     $this->swift->connection->stop();
     $this->swift->connection->start();
     $this->swift->disconnect();
     //Restart swift
     $this->swift->connect();
 }
开发者ID:AlexanderS,项目名称:Part-DB,代码行数:12,代码来源:BatchMailer.php

示例3: forceRestartSwift

 /**
  * Restarts Swift forcibly.
  */
 function forceRestartSwift()
 {
     Swift_Errors::reset();
     //Pre-empting problems trying to issue "QUIT" to a dead connection
     $this->swift->connection->stop();
     $this->swift->connection->start();
     $this->swift->disconnect();
     //Restart swift
     $this->swift->connect();
     $this->doRestart = false;
 }
开发者ID:NaszvadiG,项目名称:activecollab_loc,代码行数:14,代码来源:BatchMailer.php

示例4: connect

 /**
  * Connect to the MTA if not already connected
  */
 public function connect()
 {
     if (!$this->isConnected()) {
         try {
             $this->swift->connect();
             return true;
         } catch (Swift_ConnectionException $e) {
             $this->failed = true;
             $this->setError("Swift failed to run the connection process:<br />" . $e->getMessage());
         }
     }
     return false;
 }
开发者ID:darkcolonist,项目名称:kohana234-doctrine115,代码行数:16,代码来源:EasySwift.php

示例5: connect

 /**
  * Connect to the MTA if not already connected
  */
 function connect()
 {
     if (!$this->isConnected()) {
         Swift_Errors::expect($e, "Swift_ConnectionException");
         $this->swift->connect();
         if ($e) {
             $this->failed = true;
             $this->setError("Swift failed to run the connection process:<br />" . $e->getMessage());
             return false;
         }
         Swift_Errors::clear("Swift_ConnectionException");
     }
     return true;
 }
开发者ID:jeffthestampede,项目名称:excelsior,代码行数:17,代码来源:EasySwift.php

示例6: testDisconnectListenerRunsUponDisconnect

 public function testDisconnectListenerRunsUponDisconnect()
 {
     $conn = new FullMockConnection();
     $conn->setReturnValueAt(0, "read", "220 Hello xx");
     $conn->setReturnValueAt(1, "read", "250 Hello xxx");
     $conn->setReturnValueAt(2, "read", "221 Bye");
     $disconnect_listener = new MockDisconnectListener();
     $disconnect_listener->expectCallCount("disconnectPerformed", 1);
     $swift = new Swift($conn);
     $swift->attachPlugin($disconnect_listener, "myplugin");
     $swift->disconnect();
     $conn = new FullMockConnection();
     $conn->setReturnValueAt(0, "read", "220 Hello xx");
     $conn->setReturnValueAt(1, "read", "250 Hello xxx");
     $conn->setReturnValueAt(2, "read", "221 Bye");
     $conn->setReturnValueAt(3, "read", "220 Hello xx");
     $conn->setReturnValueAt(4, "read", "250 Hello xxx");
     $conn->setReturnValueAt(5, "read", "221 Bye");
     $conn->setReturnValueAt(6, "read", "220 Hello xx");
     $conn->setReturnValueAt(7, "read", "250 Hello xxx");
     $conn->setReturnValueAt(8, "read", "221 Bye");
     $disconnect_listener = new MockDisconnectListener();
     $disconnect_listener->expectCallCount("disconnectPerformed", 3);
     $swift = new Swift($conn);
     $swift->attachPlugin($disconnect_listener, "myplugin");
     $swift->disconnect();
     $swift->connect();
     $swift->disconnect();
     $swift->connect();
     $swift->disconnect();
 }
开发者ID:Esleelkartea,项目名称:legedia-ESLE,代码行数:31,代码来源:TestOfPluginAPI.php


注:本文中的Swift::connect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。