More tweaks
[moodle.git] / auth / pop3 / lib.php
CommitLineData
df3988ea 1<?PHP // $Id$
2 // Authentication by looking up a POP3 server
3
df3988ea 4function 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.
7
8 global $CFG;
9
10 switch ($CFG->auth_pop3type) {
11 case "pop3":
817c698e 12 $host = "{".$CFG->auth_pop3host.":$CFG->auth_pop3port/pop3}INBOX";
df3988ea 13 break;
14 case "pop3cert":
817c698e 15 $host = "{".$CFG->auth_pop3host.":$CFG->auth_pop3port/pop3/ssl/novalidate-cert}INBOX";
df3988ea 16 break;
17 }
18
35a48c9a 19 error_reporting(0);
20 $connection = imap_open($host, $username, $password, OP_HALFOPEN);
a7514c09 21 error_reporting($CFG->debug);
35a48c9a 22
23 if ($connection) {
df3988ea 24 imap_close($connection);
25 return true;
26
27 } else {
28 return false;
29 }
30}
31
32
33?>