本文整理汇总了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;
}
示例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();
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}