本文整理汇总了PHP中Swift::setOptions方法的典型用法代码示例。如果您正苦于以下问题:PHP Swift::setOptions方法的具体用法?PHP Swift::setOptions怎么用?PHP Swift::setOptions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Swift
的用法示例。
在下文中一共展示了Swift::setOptions方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}