/** * 验证邮箱密码 */ private function _validMailbox($address, $password, $host, $port, $isSsl, $protocol) { if ($protocol == 'pop3') { $mail = new Zend_Mail_Protocol_Pop3(); } else { $mail = new Zend_Mail_Protocol_Imap(); } try { $mail->connect($host, $port, $isSsl); } catch (Zend_Mail_Protocol_Exception $e) { $this->json(false, $this->lang['mailbox_connect_error']); return false; } $isValid = true; try { $mail->login($address, $password); } catch (Zend_Mail_Protocol_Exception $e) { $isValid = false; } if (!$isValid) { try { list($uid, ) = explode('@', $address, 2); $mail->login($uid, $password); $isValid = true; } catch (Zend_Mail_Protocol_Exception $e) { $this->json(false, $this->lang['mailbox_login_error']); return false; } } if ($protocol == 'pop3' && $isValid) { $msg = null; $octects = null; $isValid = true; try { $mail->status($msg, $octects); } catch (Zend_Mail_Protocol_Exception $e) { $this->json(false, $this->lang['mailbox_login_error']); $isValid = false; return false; } } if (!$isValid) { $this->json(false, $this->lang['mailbox_login_error']); return false; } //$this->json(true); return true; }