Separated code for IMAP into IMAP, POP3 and NNTP
[moodle.git] / auth / pop3 / lib.php
1 <?PHP  // $Id$
2        // Authentication by looking up a POP3 server
4 // This code is completely untested so far  -  IT NEEDS TESTERS!
5 // Looks like it should work though ...
7 $CFG->auth_pop3host   = "127.0.0.1";  // Should be IP number
8 $CFG->auth_pop3type   = "pop3";       // pop3, pop3cert
9 $CFG->auth_pop3port   = "100";        // 143, 993, 100, 119
12 function auth_user_login ($username, $password) {
13 // Returns true if the username and password work
14 // and false if they are wrong or don't exist.
16     global $CFG;
18     switch ($CFG->auth_pop3type) {
19         case "pop3":
20             $host = "{$CFG->auth_pop3host:$CFG->auth_pop3port/pop3}INBOX";
21         break;
22         case "pop3cert":
23             $host = "{$CFG->auth_pop3host:$CFG->auth_pop3port/pop3/ssl/novalidate-cert}INBOX";
24         break;
25     }
27     if ($connection = imap_open($host, $username, $password, OP_HALFOPEN)) {
28         imap_close($connection);
29         return true;
31     } else {
32         return false;
33     }
34 }
37 ?>