コード例 #1
0
ファイル: xmail.php プロジェクト: rcg2015/roundcubemail
 function save($currpass, $newpass)
 {
     $rcmail = rcmail::get_instance();
     list($user, $domain) = explode('@', $_SESSION['username']);
     $xmail = new XMail();
     $xmail->hostname = $rcmail->config->get('xmail_host');
     $xmail->username = $rcmail->config->get('xmail_user');
     $xmail->password = $rcmail->config->get('xmail_pass');
     $xmail->port = $rcmail->config->get('xmail_port');
     if (!$xmail->connect()) {
         rcube::raise_error(array('code' => 600, 'type' => 'php', 'file' => __FILE__, 'line' => __LINE__, 'message' => "Password plugin: Unable to connect to mail server"), true, false);
         return PASSWORD_CONNECT_ERROR;
     } else {
         if (!$xmail->send("userpasswd\t" . $domain . "\t" . $user . "\t" . $newpass . "\n")) {
             $xmail->close();
             rcube::raise_error(array('code' => 600, 'type' => 'php', 'file' => __FILE__, 'line' => __LINE__, 'message' => "Password plugin: Unable to change password"), true, false);
             return PASSWORD_ERROR;
         } else {
             $xmail->close();
             return PASSWORD_SUCCESS;
         }
     }
 }