3 * XMail Password Driver
5 * Driver for XMail password
8 * @author Helio Cavichiolo Jr <helio@hcsistemas.com.br>
10 * Setup xmail_host, xmail_user, xmail_pass and xmail_port into
11 * config.inc.php of password plugin as follows:
13 * $rcmail_config['xmail_host'] = 'localhost';
14 * $rcmail_config['xmail_user'] = 'YourXmailControlUser';
15 * $rcmail_config['xmail_pass'] = 'YourXmailControlPass';
16 * $rcmail_config['xmail_port'] = 6017;
20 function password_save($currpass, $newpass)
22 $rcmail = rcmail::get_instance();
23 list($user,$domain) = explode('@', $_SESSION['username']);
27 $xmail->hostname = $rcmail->config->get('xmail_host');
28 $xmail->username = $rcmail->config->get('xmail_user');
29 $xmail->password = $rcmail->config->get('xmail_pass');
30 $xmail->port = $rcmail->config->get('xmail_port');
32 if (!$xmail->connect()) {
36 'file' => __FILE__, 'line' => __LINE__,
37 'message' => "Password plugin: Unable to connect to mail server"
39 return PASSWORD_CONNECT_ERROR;
40 } else if (!$xmail->send("userpasswd\t".$domain."\t".$user."\t".$newpass."\n")) {
45 'file' => __FILE__, 'line' => __LINE__,
46 'message' => "Password plugin: Unable to change password"
48 return PASSWORD_ERROR;
51 return PASSWORD_SUCCESS;
57 var $hostname = 'localhost';
58 var $username = 'xmail';
64 socket_write($this->socket,$msg);
65 if (substr($in = socket_read($this->socket, 512, PHP_BINARY_READ),0,1) != "+") {
73 $this->socket = socket_create(AF_INET, SOCK_STREAM, 0);
74 if ($this->socket < 0)
77 $result = socket_connect($this->socket, $this->hostname, $this->port);
79 socket_close($this->socket);
83 if (substr($in = socket_read($this->socket, 512, PHP_BINARY_READ),0,1) != "+") {
84 socket_close($this->socket);
88 if (!$this->send("$this->username\t$this->password\n")) {
89 socket_close($this->socket);
97 $this->send("quit\n");
98 socket_close($this->socket);