4 * vpopmail Password Driver
6 * Driver to change passwords via vpopmaild
9 * @author Johannes Hessellund
13 function password_save($curpass, $passwd)
15 $rcmail = rcmail::get_instance();
16 // include('Net/Socket.php');
17 $vpopmaild = new Net_Socket();
19 if (PEAR::isError($vpopmaild->connect($rcmail->config->get('password_vpopmaild_host'), $rcmail->config->get('password_vpopmaild_port'), null))) {
20 return PASSWORD_CONNECT_ERROR;
23 $result = $vpopmaild->readLine();
24 if(!preg_match('/^\+OK/', $result)) {
25 $vpopmaild->disconnect();
26 return PASSWORD_CONNECT_ERROR;
29 $vpopmaild->writeLine("slogin ". $_SESSION['username'] . " " . $curpass);
30 $result = $vpopmaild->readLine();
31 if(!preg_match('/^\+OK/', $result) ) {
32 $vpopmaild->writeLine("quit");
33 $vpopmaild->disconnect();
34 return PASSWORD_ERROR;
37 $vpopmaild->writeLine("mod_user ". $_SESSION['username']);
38 $result = $vpopmaild->readLine();
39 if(!preg_match('/^\+OK/', $result) ) {
40 $vpopmaild->writeLine("quit");
41 $vpopmaild->disconnect();
42 return PASSWORD_ERROR;
45 $vpopmaild->writeLine("clear_text_password ". $passwd);
46 $vpopmaild->writeLine(".");
47 $result = $vpopmaild->readLine();
48 $vpopmaild->writeLine("quit");
49 $vpopmaild->disconnect();
50 if (!preg_match('/^\+OK/', $result))
51 return PASSWORD_ERROR;
53 return PASSWORD_SUCCESS;