/** * Check if the password is correct without logging in the user * * @param string $uid The username * @param string $password The password * * @return true/false */ public function checkPassword($uid, $password) { if (!function_exists('imap_open')) { OCP\Util::writeLog('user_external', 'ERROR: PHP imap extension is not installed', OCP\Util::ERROR); return false; } // Check if we only want logins from ONE domain and strip the domain part from UID if ($this->domain != '') { $pieces = explode('@', $uid); if (count($pieces) == 1) { $username = $uid . "@" . $this->domain; } elseif (count($pieces) == 2 and $pieces[1] == $this->domain) { $username = $uid; $uid = $pieces[0]; } else { return false; } } else { $username = $uid; } $mbox = @imap_open($this->mailbox, $username, $password, OP_HALFOPEN, 1); imap_errors(); imap_alerts(); if ($mbox !== FALSE) { imap_close($mbox); $uid = mb_strtolower($uid); $this->storeUser($uid); return $uid; } else { return false; } }
function __destruct() { // You will have iMap errors, even if there are no // mails on the server. This suppresses that error. imap_errors(); imap_close($this->connection); }
function addAccount($_hookValues) { #_debug_array($_hookValues); $username = $_hookValues['account_lid']; $userPassword = $_hookValues['new_passwd']; #_debug_array($this->profileData); $imapAdminUsername = $this->profileData['imapAdminUsername']; $imapAdminPW = $this->profileData['imapAdminPW']; $folderNames = array("user.{$username}", "user.{$username}.Trash", "user.{$username}.Sent"); // create the mailbox if ($mbox = @imap_open($this->getMailboxString(), $imapAdminUsername, $imapAdminPW)) { // create the users folders foreach ($folderNames as $mailBoxName) { if (imap_createmailbox($mbox, imap_utf7_encode("{" . $this->profileData['imapServer'] . "}{$mailBoxName}"))) { if (!imap_setacl($mbox, $mailBoxName, $username, "lrswipcd")) { # log error message } } } imap_close($mbox); } else { _debug_array(imap_errors()); return false; } // subscribe to the folders if ($mbox = @imap_open($this->getMailboxString(), $username, $userPassword)) { imap_subscribe($mbox, $this->getMailboxString('INBOX')); imap_subscribe($mbox, $this->getMailboxString('INBOX.Sent')); imap_subscribe($mbox, $this->getMailboxString('INBOX.Trash')); imap_close($mbox); } else { # log error message } }
/** * Primary method for downloading and processing email replies */ public function download_and_process_email_replies($connection_details) { imap_timeout(IMAP_OPENTIMEOUT, apply_filters('supportflow_imap_open_timeout', 5)); $ssl = $connection_details['imap_ssl'] ? '/ssl' : ''; $ssl = apply_filters('supportflow_imap_ssl', $ssl, $connection_details['imap_host']); $mailbox = "{{$connection_details['imap_host']}:{$connection_details['imap_port']}{$ssl}}"; $inbox = "{$mailbox}{$connection_details['inbox']}"; $archive_box = "{$mailbox}{$connection_details['archive']}"; $imap_connection = imap_open($mailbox, $connection_details['username'], $connection_details['password']); $redacted_connection_details = $connection_details; $redacted_connection_details['password'] = '******'; // redact the password to avoid unnecessarily exposing it in logs $imap_errors = imap_errors(); SupportFlow()->extend->logger->log('email_retrieve', __METHOD__, $imap_connection ? __('Successfully opened IMAP connection.', 'supportflow') : __('Failed to open IMAP connection.', 'supportflow'), compact('redacted_connection_details', 'mailbox', 'imap_errors')); if (!$imap_connection) { return new WP_Error('connection-error', __('Error connecting to mailbox', 'supportflow')); } // Check to see if the archive mailbox exists, and create it if it doesn't $mailboxes = imap_getmailboxes($imap_connection, $mailbox, '*'); if (!wp_filter_object_list($mailboxes, array('name' => $archive_box))) { imap_createmailbox($imap_connection, $archive_box); } // Make sure here are new emails to process $email_count = imap_num_msg($imap_connection); if ($email_count < 1) { SupportFlow()->extend->logger->log('email_retrieve', __METHOD__, __('No new messages to process.', 'supportflow'), compact('mailboxes')); return false; } $emails = imap_search($imap_connection, 'ALL', SE_UID); $email_count = min($email_count, apply_filters('supportflow_max_email_process_count', 20)); $emails = array_slice($emails, 0, $email_count); $processed = 0; // Process each new email and put it in the archive mailbox when done. foreach ($emails as $uid) { $email = new stdClass(); $email->uid = $uid; $email->msgno = imap_msgno($imap_connection, $email->uid); $email->headers = imap_headerinfo($imap_connection, $email->msgno); $email->structure = imap_fetchstructure($imap_connection, $email->msgno); $email->body = $this->get_body_from_connection($imap_connection, $email->msgno); if (0 === strcasecmp($connection_details['username'], $email->headers->from[0]->mailbox . '@' . $email->headers->from[0]->host)) { $connection_details['password'] = '******'; // redact the password to avoid unnecessarily exposing it in logs SupportFlow()->extend->logger->log('email_retrieve', __METHOD__, __('Skipping message because it was sent from a SupportFlow account.', 'supportflow'), compact('email')); continue; } // @todo Confirm this a message we want to process $result = $this->process_email($imap_connection, $email, $email->msgno, $connection_details['username'], $connection_details['account_id']); // If it was successful, move the email to the archive if ($result) { imap_mail_move($imap_connection, $email->uid, $connection_details['archive'], CP_UID); $processed++; } } imap_close($imap_connection, CL_EXPUNGE); $status_message = sprintf(__('Processed %d emails', 'supportflow'), $processed); SupportFlow()->extend->logger->log('email_retrieve', __METHOD__, $status_message); return $status_message; }
public function Close() { //$this->IMAP2->setOptions('close', CL_EXPUNGE); $this->IMAP2->Expunge(); $this->IMAP2->Close(); imap_errors(); // Clear error stack. }
public function grabEventsFromEmailAction() { //echo phpinfo(); $m = new manage_model_event(); $m->emailGrab(); core_debug::dump($m); core_debug::dump(imap_errors()); die('at ctrl'); }
public function __construct($mailbox, $username, $password, $code = null, $previous = null) { $this->mailbox = $mailbox; $this->username = $username; $this->password = $password; $this->imapErrors = \imap_errors(); $message = 'Error connecting to: '.$mailbox.' with user: '******' ['. \imap_last_error().']'; parent::__construct($message, $code, $previous); }
/** * Constructor - Establishes Connection to Email Host */ function __construct($emailHost, $emailPort, $emailOptions, $emailLogin, $emailPassword, $catchAllBase = NULL) { $hostString = "{{$emailHost}:{$emailPort}/{$emailOptions}}"; $this->mbox = imap_open($hostString, $emailLogin, $emailPassword, OP_SILENT) or die("can't connect: " . print_r(imap_errors())); // Remove all mail that may have been marked for deletion // via another process, E.g script that died imap_expunge($this->mbox); $this->connected = TRUE; $this->catchAllBase = $catchAllBase; }
function open($mailbox = '') { if ($this->stream) { $this->close(); } $this->target = "{" . $this->host . ":" . $this->port . "/" . $this->mode . ($this->security != "none" ? "/" . $this->security . "/novalidate-cert" : "") . "/readonly}"; $this->stream = imap_open($this->target . $mailbox, $this->username, $this->password); if (!$this->stream) { throw new \Exception(implode(", ", imap_errors())); } }
/** * @brief Check if the password is correct * @param $uid The username * @param $password The password * @returns true/false * * Check if the password is correct without logging in the user */ public function checkPassword($uid, $password) { $mbox = @imap_open($this->mailbox, $uid, $password); imap_errors(); imap_alerts(); if ($mbox) { imap_close($mbox); return $uid; } else { return false; } }
/** * Set the server, login, pass, service_flags, and mailbox * */ public function initialize($init_array) { // connect to the specified account // these array items need to be the // same names as the config items OR // the db table fields that store the account info $this->host = $init_array['host']; $this->port = $init_array['port']; // get the port and server combined $this->server = $this->host . ':' . $this->port; $this->login = $init_array['login']; $this->pass = $init_array['pass']; $this->service_flags = $init_array['service_flags']; // default to INBOX mailbox since POP3 doesn't require it // and IMAP always has an INBOX $this->mailbox = isset($init_array['mailbox']) ? $init_array['mailbox'] : 'INBOX'; // grab the resource returned by imap_open() // concatenate the IMAP connect spec string // expects server, flags, and mailbox to be set already $this->server_spec_string = $this->_generate_server_spec_string(); // suppress warning with @ so we can handle it internally // which is the way that imap_errors() works $this->resource = @imap_open($this->server_spec_string, $this->login, $this->pass); // check for errors in the connection // calling imap_errors() clears all errors in the stack $err = imap_errors(); // clear the message count in case this is a re-initialization $this->message_count = NULL; if ($this->resource) { $this->log_state('Connected to: ' . $this->server_spec_string); // when connection is good but the mailbox is empty, // the php imap c-libs report POP server empty mailbox as // "Mailbox is empty" (as a PHP error in the imap_errors() stack) // in case we are using IMAP, we also check get_message_count() if ($err[0] === 'Mailbox is empty' or $this->get_message_count() === 0) { // we now know there are zero messages $this->message_waiting = FALSE; $this->log_state('Mailbox is empty.'); } else { // there is at least one message $this->message_waiting = TRUE; $this->log_state('At least one message available.'); } $this->connected = TRUE; } else { // determine the specific reason for rejection/no connection $this->_handle_rejection($err); $this->log_state('Not connected. No email resource at: ' . $this->server_spec_string); $this->connected = FALSE; } }
function Logoff() { if ($this->_mbox) { // list all errors $errors = imap_errors(); if (is_array($errors)) { foreach ($errors as $e) { debugLog("IMAP-errors: {$e}"); } } @imap_close($this->_mbox); debugLog("IMAP connection closed"); } }
/** * Authenticate connection * * @param string $username Username * @param string $password Password * * @return \Ddeboer\Imap\Connection * @throws AuthenticationFailedException */ public function authenticate($username, $password) { $resource = @\imap_open($this->getServerString(), $username, $password, null, 1); if (false === $resource) { throw new AuthenticationFailedException($username); } $check = imap_check($resource); $mailbox = $check->Mailbox; $this->connection = substr($mailbox, 0, strpos($mailbox, '}') + 1); // These are necessary to get rid of PHP throwing IMAP errors imap_errors(); imap_alerts(); return new Connection($resource, $this->connection); }
function get_imap_connection() { $mbox = imap_open("{xxx.xxx.xxx.xxx:xxx/pop3/novalidate-cert}INBOX", "xml", "password") or die("can't connect: " . imap_last_error()); if ($mbox) { // call this to avoid the mailbox is empty error message if (imap_num_msg($mbox) == 0) { $errors = imap_errors(); if ($errors) { die("can't connect: " . imap_last_error()); } } } return $mbox; }
public function open($server, $username, $password, $mailbox, array $flags) { if (!empty($flags)) { $server .= '/' . implode('/', $flags); } $mailbox = '{' . $server . '}' . $mailbox; $this->resource = @imap_open($mailbox, $username, $password); if (!$this->resource) { $error = imap_last_error(); imap_errors(); imap_alerts(); throw new IMAPException($error); } return $this; }
public function connect($mailboxName = '', $attempts = 3) { $this->resource = $this->getAddress($mailboxName); if ($this->connection != false) { $this->disconnect(); } $options = $this->read_only ? OP_READONLY : 0; try { $this->connection = imap_open($this->resource, $this->username, $this->password, $options, $attempts); } catch (\ErrorException $e) { $message = $e->getMessage() . '. ' . implode("; ", imap_errors()); throw new ConnectionFailedException($message); } return $this; }
/** * Show the application welcome screen to the user. * * @return Response */ public function index() { /* - - - - - - - Gmail - - - - - - */ $stream = imap_open("{uranus.o2switch.net:993/imap/SSL}INBOX", "*****@*****.**", "N4tu73&P"); $check = imap_check($stream); $list = imap_list($stream, "{uranus.o2switch.net}", "*"); $getmailboxes = imap_getmailboxes($stream, "{uranus.o2switch.net}", "*"); $headers = imap_headers($stream); $num_msg = imap_num_msg($stream); $status = imap_status($stream, "{uranus.o2switch.net:993/imap/SSL}INBOX", SA_ALL); $messages = imap_fetch_overview($stream, "1:" . $num_msg); $body = imap_body($stream, '1'); $close = imap_close($stream); $errors = imap_errors(); return view('Imap.Imap')->with(compact('resource'))->with(compact('check'))->with(compact('list'))->with(compact('getmailboxes'))->with(compact('headers'))->with(compact('num_msg'))->with(compact('status'))->with(compact('errors'))->with(compact('messages'))->with(compact('body')); }
/** * Connects to an IMAP or POP3 server * * Please note that a connection to a POP3 server will have data remain * static over the lifetime of the connection, but an IMAP connection will * update in real time. * * @param string $host The POP3 host name * @param string $user The user to log in as * @param string $password The user's password * @param string $type The type of connection: 'imap' or 'pop3' * @param integer $port The POP3 - only required if non-standard * @param boolean $ssl If SSL should be used for the connection * @param boolean $silence_errors If imap errors should be silenced * @return fPOP3 */ public function __construct($host, $user, $password, $type = 'imap', $port = NULL, $ssl = FALSE, $silence_errors = FALSE) { if ($type == 'imap' && $port === NULL) { $port = 143; } elseif ($type == 'pop3' && $port === NULL) { $port = 110; } $this->resource = imap_open('{' . $host . ':' . $port . '/' . $type . (!$ssl ? "/novalidate-cert" : "") . '}INBOX', $user, $password); $errors = imap_errors(); if ($errors) { $errors = array_diff($errors, array('Mailbox is empty')); } if ($errors && !$silence_errors) { throw new fConnectivityException("The following IMAP errors occurred while connecting:\n%s", join("\n", $errors)); } }
/** * Validates a username and password over ldap * * @param string $username * @param string $password * @return bool */ public function validateUserPassExternal($username, $password) { /* build connection string */ $cert = BAIKAL_DAV_MAIL_CHECK_CERT ? "/validate-cert" : "/novalidate-cert"; $url = ""; switch (BAIKAL_DAV_MAIL_PROTOCOL) { case "imap": $url = "{" . BAIKAL_DAV_MAIL_SERVER . "/imap/notls}INBOX"; break; case "imaps": $url = "{" . BAIKAL_DAV_MAIL_SERVER . "/imap/ssl{$cert}}INBOX"; break; case "imaptls": $url = "{" . BAIKAL_DAV_MAIL_SERVER . "/imap/tls{$cert}}INBOX"; break; case "pop3": $url = "{" . BAIKAL_DAV_MAIL_SERVER . "/pop3/notls}"; break; case "pop3s": $url = "{" . BAIKAL_DAV_MAIL_SERVER . "/pop3/ssl{$cert}}"; break; case "pop3tls": $url = "{" . BAIKAL_DAV_MAIL_SERVER . "/pop3/tls{$cert}}"; break; case "smtp": $url = "{" . BAIKAL_DAV_MAIL_SERVER . "/smtp/notls}"; break; case "smtps": $url = "{" . BAIKAL_DAV_MAIL_SERVER . "/smtp/ssl{$cert}}"; break; case "smtptls": $url = "{" . BAIKAL_DAV_MAIL_SERVER . "/smtp/tls{$cert}}"; break; } /* connect to mail server (only one try) */ set_error_handler("\\Baikal\\Core\\MailAuth::exception_error_handler"); $conn = imap_open($url, $username, $password, NULL, 0); restore_error_handler(); if (!$conn) { return false; } /* skip notices, warnings and errors */ imap_errors(); /* close */ imap_close($conn); return true; }
/** * POP3アカウントに接続 * * @param String $host * @param String $port * @param String $user * @param String $pass * @return vold * @codeCoverageIgnore */ public function __construct($host, $user, $pass, $port = '110') { try { $this->inbox = imap_open('{' . $host . ':' . $port . '/pop3}', $user, $pass); $check = imap_check($this->inbox); $this->count = $check->Nmsgs; $this->overview = imap_fetch_overview($this->inbox, "1:{$this->count}", 0); foreach ($this->overview as $item) { $this->ids[] = $item->msgno; } } catch (Exception $e) { $erros = implode("; ", imap_errors()); $msg = $e->getMessage(); $ms = $msg . "\nPOP3 Errors: {$errors}"; throw new Exception($mes); } }
public function __construct($email, $id, $pwd) { if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { throw new Exception('Invalid email', 20001); } preg_match('/(?<=\\@)(.*?)(?=\\.)/', $email, $matches); $this->email = $email; $this->id = $id; $this->pwd = $pwd; $this->url = 'http://' . $matches[0] . '.com'; echo $matches[0]; $this->feed = imap_open('{' . ImapAdr::getImapAdr($matches[0]) . '/pop3/ssl}INBOX', $email, $pwd); if (!$this->feed) { print_r(imap_errors()); throw new Exception('Invalid userame, password or mail, or unsupported mailer.', 20002); } }
/** * Check if the password is correct without logging in the user * * @param string $uid The username * @param string $password The password * * @return true/false */ public function checkPassword($uid, $password) { if (!function_exists('imap_open')) { OCP\Util::writeLog('user_external', 'ERROR: PHP imap extension is not installed', OCP\Util::ERROR); return false; } $mbox = @imap_open($this->mailbox, $uid, $password, OP_HALFOPEN); imap_errors(); imap_alerts(); if ($mbox !== FALSE) { imap_close($mbox); $this->storeUser($uid); return $uid; } else { return false; } }
function createmailbox($mbox, $server, $mailbox) { global $src_username; $mailbox = mb_convert_encoding($mailbox, "UTF7-IMAP", "ISO_8859-1"); if (@imap_createmailbox($mbox, "{" . $server . "}{$mailbox}")) { $status = @imap_status($mbox, "{" . $server . "}" . $mailbox, SA_ALL); if ($status) { print "{$src_username} - {$mailbox}:\n"; print "UIDvalidity:" . $status->uidvalidity . "\n\n"; imap_subscribe($mbox, "{" . $server . "}{$mailbox}"); } else { print "imap_status on new mailbox - {$mailbox} failed: " . imap_last_error() . "\n"; } } else { print "could not create new mailbox - {$mailbox}: " . implode("\n", imap_errors()) . "\n"; } }
function connect() { $this->conn = @imap_open('{' . $this->server . '/notls}', $this->user, $this->pass, null, 1); // Supress alerts imap_alerts(); $errors = imap_errors(); $searchword = 'AUTHENTICATIONFAILED'; $matches = array_filter($errors, function ($var) use($searchword) { return preg_match("/\\b{$searchword}\\b/i", $var); }); if (is_bool($this->conn) || !empty($matches)) { $this->connected = false; return false; } else { $this->connected = true; return true; } }
function imap_open_url($u, $options = array('imap', 'notls')) { $t = parse_url($u); foreach ($t as $k => $v) { $t[$k] = rawurldecode($v); } extract($t); extract(imap_parse_path($path)); if (!$mailbox) { $options2 = OP_HALFOPEN; } $c = imap_open('{' . $host . '/' . join('/', $options) . '}' . $mailbox, $user, $pass, $options2); if (!$c) { print_r(imap_errors()); return FALSE; } return $c; }
static function fetch($options) { if ($mbox = imap_open(sprintf('{%1$s:%2$s/%3$s}INBOX', $options['server'], $options['port'], implode('/', $options['settings'])), $options['user'], $options['pass'])) { $ret = array(); if (($messages = imap_num_msg($mbox)) > 0) { for ($message = 1; $message < $messages + 1; $message++) { $eml = imap_fetchheader($mbox, $message) . imap_body($mbox, $message); $data = array('Task' => array()); $email_data = LilTasksParseEmail::__parseEmailHeader($mbox, $message); $data['Task']['title'] = $email_data['subject']; $data['Task']['happened'] = strftime('%Y-%m-%d', strtotime($email_data['date'])); list($sender, $domain) = explode('@', $email_data['from']); if ($sender == 'today') { $data['Task']['deadline'] = strftime('%Y-%m-%d'); } else { if ($sender == 'tomorrow') { $data['Task']['deadline'] = strftime('%Y-%m-%d', time() + 24 * 60 * 60); } else { if (in_array(strtolower($sender), array('monday', 'tuesday', 'wednesday', 'thursday', 'saturday', 'sunday'))) { $data['Task']['deadline'] = strftime('%Y-%m-%d', strtotime('next ' . ucfirst($sender))); } } } $hash = sha1($data['Task']['happened'] . '_' . $email_data['subject']); $parts = array(); $data['Task']['descript'] = LilTasksParseEmail::__parseEmailBody($mbox, $message, $hash, $parts); file_put_contents(TMP . $hash . '.eml', $eml); $data['Attachment'][0] = array('model' => 'Task', 'filename' => array('name' => $hash . '.eml', 'tmp_name' => TMP . $hash . '.eml'), 'title' => 'SOURCE: ' . $data['Task']['title']); App::uses('Sanitize', 'Utility'); foreach ($parts as $part) { if (!empty($part['attachment'])) { $data['Attachment'][] = array('model' => 'Task', 'filename' => array('name' => Sanitize::paranoid($part['attachment']['filename']), 'tmp_name' => $part['attachment']['tmp']), 'title' => $part['attachment']['filename']); } } $ret[$message] = $data; imap_delete($mbox, $message); } } return $ret; imap_close($mbox, CL_EXPUNGE); } else { var_dump(imap_errors()); } }
public function authenticate(array $credentials) { list($username, $password) = $credentials; $loginData = $this->imapLoginModel->getBy(array("username" => $username)); $mbox = imap_open("{localhost:993/ssl/novalidate-cert}INBOX", $username, $password, OP_HALFOPEN | OP_SILENT); imap_alerts(); imap_errors(); if (!$loginData) { throw new \Nette\Security\AuthenticationException('Neznámé jméno uživatele.', self::IDENTITY_NOT_FOUND); } elseif (!$mbox) { throw new \Nette\Security\AuthenticationException('Nesprávné heslo.', self::INVALID_CREDENTIAL); } $identity = $this->buildIdentity($loginData->user_id); $enabled = $identity->getData()["enabled"]; if (!$enabled) { throw new \Nette\Security\AuthenticationException('Tento účet je zablokovaný.', self::INACTIVE); } $this->user->login($identity); }
/** * Authenticate connection * * @param string $username Username * @param string $password Password * * @return Connection * @throws AuthenticationFailedException */ public function authenticate($username, $password) { // Wrap imap_open, which gives notices instead of exceptions set_error_handler(function ($nr, $message) use($username) { throw new AuthenticationFailedException($username, $message); }); $resource = imap_open($this->getServerString(), $username, $password, null, 1, $this->parameters); if (false === $resource) { throw new AuthenticationFailedException($username); } restore_error_handler(); $check = imap_check($resource); $mailbox = $check->Mailbox; $this->connection = substr($mailbox, 0, strpos($mailbox, '}') + 1); // These are necessary to get rid of PHP throwing IMAP errors imap_errors(); imap_alerts(); return new Connection($resource, $this->connection); }
/** * Authenticates user * @param string $username * @param string $password * @param string $domain * @return boolean */ function authUser($username, $password, $domain) { $fulluser = $domain . '/' . $username; $mbox = imap_open('{' . $this->exchHost . '/imap}Inbox', $fulluser, $password); if ($mbox === false) { $this->err_msg = translate('Invalid Username/Password'); return false; } else { $ignore = imap_errors(); imap_close($mbox); } $ldapconn = ldap_connect($this->exchLDAP); if ($ldapconn === false) { $this->err_msg = translate('Can not connect to LDAP server'); return false; } ldap_set_option($ldapconn, LDAP_OPT_PROTOCOL_VERSION, 3); ldap_set_option($ldapconn, LDAP_OPT_REFERRALS, 0); $ldapbind = ldap_bind($ldapconn); if ($ldapbind === false) { $this->err_msg = translate('Can not bind to LDAP server'); return false; } $ldapattr = array('cn', 'rfc822Mailbox', 'otherMailbox'); $read = ldap_search($ldapconn, '', '(uid=' . $username . ')', $ldapattr); if ($read === false) { $this->err_msg = translate('Unable to search LDAP server'); return false; } $info = ldap_get_entries($ldapconn, $read); $this->logonName = strtolower($username); $this->firstName = $info[0]['cn'][0]; $this->emailAddress[] = strtolower($info[0]['rfc822mailbox'][0]); for ($i = 0; $i < $info[0]['othermailbox']['count']; $i++) { $data = $info[0]['othermailbox'][$i]; if (strncasecmp($data, 'smtp$', 5) == 0) { $this->emailAddress[] = strtolower(substr($data, 5)); } } ldap_close($ldapconn); return true; }
function validate($user, $pass, $challenge, $response) { parent::validate($user, $pass, $challenge, $response); $mailbox = '{' . $this->mConfig['server']; if ($this->mConfig["ssl"]) { $mailbox .= "/ssl"; if ($this->mConfig["sslvalidate"]) { $mailbox .= "/validate-cert"; } else { $mailbox .= "/novalidate-cert"; } } $mailbox .= ':' . $this->mConfig["port"] . '}INBOX'; $imapauth = @imap_open($mailbox, $user, $pass); if (!$imapauth) { $this->mErrors['login'] = imap_errors(); $ret = USER_NOT_FOUND; } else { $ret = USER_VALID; $this->mInfo["real_name"] = $user; if (empty($this->mConfig["email"])) { $this->mInfo["email"] = $user; } else { $info = array('login' => $user); $replace_func = create_function('$matches', '$info = ' . var_export($info, true) . '; $m = $matches[0]; $m = substr($m,1,strlen($m)-2); if(empty($info[$m])) return ""; return strtolower($info[$m]);'); $this->mInfo["email"] = preg_replace_callback('/%.*?%/', $replace_func, $this->mConfig["email"]); } imap_close($imapauth); } return $ret; }