Problems with pop3 authentication

Problems with pop3 authentication

by Zbigniew Fiedorowicz -
Number of replies: 2

I spent a long frustrating day yesterday getting our Moodle installation to work properly, after our system administrator upgraded the server OS from Red Hat 9 to Red Hat Enterprise. One problem was that newly uploaded profile images displayed as black squares. See http://moodle.org/mod/forum/discuss.php?d=10415#53592 for further details.

Another problem was that pop server authentication would not work. After a lot of experimentation, I found that I needed to make the following changes in auth/pop3/lib.php:

switch ($CFG->auth_pop3type) {
    case "pop3":
        $host = '{'.$host.":$CFG->auth_pop3port/pop3}INBOX";
    break;
    case "pop3notls":
        $host = '{'.$host.":$CFG->auth_pop3port/pop3/notls}INBOX";
    break;
    case "pop3cert":
        $host = '{'.$host.":$CFG->auth_pop3port/pop3/ssl/novalidate-cert}INBOX";
    break;
}
error_reporting(0);
$connection = imap_open($host, $username, $password, OP_HALFOPEN);


to

switch ($CFG->auth_pop3type) {
    case "pop3":
        $host = '{'.$host.":$CFG->auth_pop3port/pop3/user=$username}INBOX";
    break;
    case "pop3notls":
        $host = '{'.$host.":$CFG->auth_pop3port/pop3/notls/user=$username}INBOX";
    break;
    case "pop3cert":
        $host = '{'.$host.":$CFG->auth_pop3port/pop3/ssl/novalidate-cert/user=$username}INBOX";
    break;
}
error_reporting(0);
$connection = imap_open($host, $username, $password);

Note in particular that the OP_HALFOPEN option needed to be removed. [The documentation on php.net indicates that this option should only be used with imap and nntp, not pop3.]

These changes might be related to the fact that the old server was using the Cyrus imap client, whereas the new server uses the c-client imap client. After making these changes, pop3 authentication is much snappier than under the old server. It could be that the old imap client was failing and retrying with variations, whereas the new c-client makes only one try with the specified syntax for the pop3 connection.

Average of ratings: Useful (1)
In reply to Zbigniew Fiedorowicz

Re: Problems with pop3 authentication

by Peter Davis -

I also had a similar problem, I actully modified the pop3 auth file quite drastically to get it working.

I actully circumvented the need to use phpimap librarys and handled the pop3 authentication at the protocol level. I was finding that it would authenticate to my pop3 server when it wasn't authenticating back to a domain controler once I set that up it stoped working I assumed it was some strange timing problem so I believed this to be an appropriate solution in my case.

Attached is my modified pop3/lib.php which over came the problem.

Regards Peter.