當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。