More tweaks
[moodle.git] / auth / pop3 / lib.php
1 <?PHP  // $Id$
2        // Authentication by looking up a POP3 server
4 function auth_user_login ($username, $password) {
5 // Returns true if the username and password work
6 // and false if they are wrong or don't exist.
8     global $CFG;
10     switch ($CFG->auth_pop3type) {
11         case "pop3":
12             $host = "{".$CFG->auth_pop3host.":$CFG->auth_pop3port/pop3}INBOX";
13         break;
14         case "pop3cert":
15             $host = "{".$CFG->auth_pop3host.":$CFG->auth_pop3port/pop3/ssl/novalidate-cert}INBOX";
16         break;
17     }
19     error_reporting(0);
20     $connection = imap_open($host, $username, $password, OP_HALFOPEN);
21     error_reporting($CFG->debug);   
23     if ($connection) {
24         imap_close($connection);
25         return true;
27     } else {
28         return false;
29     }
30 }
33 ?>