I wrote a new auth module for authentication with remote IMAP servers. My hook_auth implementation returns TRUE but users can't login. Should I implement another hooks?
Any hint? This is the code:
<?php
...
/**
* Implementation of hook_auth().
*/
function imapauth_auth($username, $password, $server) {
//IMAP extension not loaded
if (!function_exists('imap_open')) {
watchdog('php', t('IMAP extension not loaded. IMAP module couldn\'t be used to authenticate users.'), WATCHDOG_WARNING);
return false;
}
if (variable_get('imapauth_enabled', 0) == 0) {
return false;
}
$domains = split("/\r\n|\n|\r/", variable_get('imapauth_domains', array()));
$valid = false;
foreach ($domains as $d) {
$domain_settings = split(",", $d, 2);
if ((trim($domain_settings[0]) == $server) or trim($domain_settings[0]) == '*') {
$valid = true;
if (array_key_exists(1, $domain_settings)) {
$mailbox = trim($domain_settings[1]);
}
else {
$mailbox = "{" . $server . ":143}INBOX";
}
}
}
//This domain is not valid for IMAP authentication
if (!$valid) {
return false;
}
$mbox = @imap_open($mailbox, $username, $password);
if ($mbox) {
$minfo = @imap_mailboxmsginfo($mbox);
if ($minfo) {
$login = true;
}
else {