Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added POP-before-SMTP Support

Ignore-this: 6df5ad3a74b32e27ae808bb19a2435f5

The Swift-Class for POP-before-SMTP had a bug and was missing logging. This
was fixed.

darcs-hash:20090808191324-7ad00-20923c1f429d6dd325e7a8104166ad770a20d284.gz
  • Loading branch information...
commit ddfbbb601d1b70684d2fbc384ae7bdc6d792eaf8 1 parent 4cfe9b9
@splitbrain authored
View
1  Swift/Authenticator/@PopB4Smtp.php
@@ -65,6 +65,7 @@ public function isAuthenticated($user, $pass, Swift $swift)
} 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;
View
29 Swift/Authenticator/PopB4Smtp/Pop3Connection.php
@@ -41,7 +41,7 @@ class Swift_Authenticator_PopB4Smtp_Pop3Connection
* @var resource
*/
protected $handle = null;
-
+
/**
* Constructor
* @param string The name of the POP3 server
@@ -123,8 +123,14 @@ public function start()
{
$url = $this->getServer();
if ($this->getEncryption() == self::ENC_SSL) $url = "ssl://" . $url;
-
- if ((false === $this->handle = fsockopen($url, $this->getPort(), $errno, $errstr, $timeout)))
+
+ $log = Swift_LogContainer::getLog();
+ if ($log->hasLevel(Swift_Log::LOG_NETWORK))
+ {
+ $log->add("Trying to connect to POP3 server ".$url." on port ".$this->getPort());
+ }
+
+ if ((false === $this->handle = @fsockopen($url, $this->getPort(), $errno, $errstr, 5)))
{
Swift_ClassLoader::load("Swift_ConnectionException");
throw new Swift_ConnectionException("The POP3 connection failed to start. The error string returned from fsockopen() is [" . $errstr . "] #" . $errno);
@@ -158,7 +164,14 @@ public function read()
Swift_ClassLoader::load("Swift_ConnectionException");
throw new Swift_ConnectionException("Data could not be read from the POP3 connection.");
}
- return trim($response);
+ $response = trim($response);
+
+ $log = Swift_LogContainer::getLog();
+ if ($log->hasLevel(Swift_Log::LOG_NETWORK))
+ {
+ $log->add($response,Swift_Log::RESPONSE);
+ }
+ return $response;
}
/**
* Write a command to the remote socket
@@ -167,10 +180,16 @@ public function read()
*/
public function write($command)
{
- if (false !== fwrite($this->handle, $command . "\r\n"))
+ if (false === fwrite($this->handle, $command . "\r\n"))
{
Swift_ClassLoader::load("Swift_ConnectionException");
throw new Swift_ConnectionException("Data could not be written to the POP3 connection.");
}
+
+ $log = Swift_LogContainer::getLog();
+ if ($log->hasLevel(Swift_Log::LOG_NETWORK))
+ {
+ $log->add($command,Swift_Log::COMMAND);
+ }
}
}
View
6 action.php
@@ -63,6 +63,12 @@ function handle_message_send(&$event, $param){
$this->getConf('smtp_ssl')
);
+ // use Pop-before-SMTP
+ if($this->getConf('pop3_host')) {
+ require_once dirname(__FILE__).'/Swift/Authenticator/@PopB4Smtp.php';
+ $smtp->attachAuthenticator(new Swift_Authenticator_PopB4Smtp($this->getConf('pop3_host')));
+ }
+
// use SMTP auth?
if($this->getConf('auth_user')) $smtp->setUsername($this->getConf('auth_user'));
if($this->getConf('auth_pass')) $smtp->setPassword($this->getConf('auth_pass'));
View
1  conf/default.php
@@ -8,5 +8,6 @@
$conf['auth_user'] = '';
$conf['auth_pass'] = '';
+$conf['pop3_host'] = '';
$conf['debug'] = 0;
View
1  conf/metadata.php
@@ -6,6 +6,7 @@
$meta['auth_user'] = array('string');
$meta['auth_pass'] = array('password');
+$meta['pop3_host'] = array('string');
$meta['localdomain'] = array('string');
View
1  lang/en/settings.php
@@ -10,6 +10,7 @@
$lang['auth_user'] = 'If authentication is required, put your user name here.';
$lang['auth_pass'] = 'Password for the above user.';
+$lang['pop3_host'] = 'If your server uses POP-before-SMTP for authentication, give your POP3 credentials above and put your POP3 server here. For usual SMTP auth leave this field empty.';
$lang['localdomain'] = 'The name to be used during HELO phase of SMTP. Should be the FQDN of the webserver DokuWiki is running on. Leave empty for autodetection.';
Please sign in to comment.
Something went wrong with that request. Please try again.