| Copyright (c) 2006 Palosanto Solutions S. A. | +----------------------------------------------------------------------+ | Cdla. Nueva Kennedy Calle E 222 y 9na. Este | | Telfs. 2283-268, 2294-440, 2284-356 | | Guayaquil - Ecuador | | http://www.palosanto.com | +----------------------------------------------------------------------+ | The contents of this file are subject to the General Public License | | (GPL) Version 2 (the "License"); you may not use this file except in | | compliance with the License. You may obtain a copy of the License at | | http://www.opensource.org/licenses/gpl-license.php | | | | Software distributed under the License is distributed on an "AS IS" | | basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See | | the License for the specific language governing rights and | | limitations under the License. | +----------------------------------------------------------------------+ | The Original Code is: Elastix Open Source. | | The Initial Developer of the Original Code is PaloSanto Solutions | +----------------------------------------------------------------------+ $Id: email.conf.php,v 1.1.1.1 2007/07/06 21:31:56 gcarrillo Exp $ */ $configPostfix2 = isPostfixToElastix2(); // in misc.lib.php $clave = obtenerClaveCyrusAdmin(); if (!$configPostfix2) { define("SASL_DOMAIN", "example.com"); } $GLOBALS['CYRUS'] = array('HOST' => "localhost", 'PORT' => 143, 'ADMIN' => 'cyrus', 'PASS' => $clave); $script = "require [\"fileinto\",\"vacation\"];\n"; $script .= "if header :contains \"X-Spam-Status\" \"Yes,\" {\n" . " fileinto \"spam\";\n" . "}\n" . "\r\n"; define("DEFAULT_SCRIPT", $script);
function resconstruirMailBox($username) { $output = $retval = NULL; $configPostfix2 = isPostfixToElastix2(); // in misc.lib.php $regularExpresion = ""; if ($configPostfix2) { $regularExpresion = '/^[a-z0-9]+([\\._\\-]?[a-z0-9]+[_\\-]?)*@[a-z0-9]+([\\._\\-]?[a-z0-9]+)*(\\.[a-z0-9]{2,6})+$/'; } else { $regularExpresion = '/^([a-z0-9]+([\\._\\-]?[a-z0-9]+[_\\-]?)*)$/'; } if (!is_null($username)) { if (!preg_match($regularExpresion, $username)) { $this->errMsg = _tr("Username is not valid"); } else { exec('/usr/bin/elastix-helper email_account --reconstruct_mailbox --mailbox ' . escapeshellarg($username) . ' 2>&1', $output, $retval); } } else { $this->errMsg = _tr("Username can't be empty"); } if ($retval != 0) { $this->errMsg = implode('', $output); return FALSE; } return TRUE; }
/** * Actualizar la cuota del usuario indicado, tanto en cyrus como en la DB. * * @param string $username Correo completo usuario@dominio.com * @param int $newquota Nueva cuota de correo a asignar * * @return bool VERDADERO en caso de éxito, FALSO en caso de error. */ function setAccountQuota($username, $newquota) { $this->errMsg = ''; $bPostfixElastix2 = isPostfixToElastix2(); $regexp = $bPostfixElastix2 ? '/^[a-z0-9]+([\\._\\-]?[a-z0-9]+[_\\-]?)*@[a-z0-9]+([\\._\\-]?[a-z0-9]+)*(\\.[a-z0-9]{2,6})+$/' : '/^([a-z0-9]+([\\._\\-]?[a-z0-9]+[_\\-]?)*)$/'; if (!preg_match($regexp, $username)) { $this->errMsg = _tr('Username is not valid'); return FALSE; } $cyr_conn = new cyradm(); if (!$cyr_conn->imap_login()) { $this->errMsg = _tr('Failed to login to IMAP'); return NULL; } $this->_DB->beginTransaction(); $sPeticionSQL = 'UPDATE accountuser SET quota = ? WHERE username = ?'; $bExito = $this->_DB->genQuery($sPeticionSQL, array($newquota, $username)); if (!$bExito) { $this->errMsg = $this->_DB->errMsg; } else { $bExito = $cyr_conn->setmbquota('user/' . $username, $newquota); if (!$bExito) { $this->errMsg = $cyr_conn->getMessage(); } } if ($bExito) { $this->_DB->commit(); } else { $this->_DB->rollback(); } $cyr_conn->imap_logout(); return $bExito; }
function create_email_account($pDB, $domain_name, &$errMsg) { $pEmail = new paloEmail($pDB); //creo la cuenta // -- valido que el usuario no exista // -- si no existe creo el usuario en el sistema con sasldbpasswd2 // -- inserto el usuario en la base de datos // -- si hay error al insertarlo en la bd lo elimino del sistema // -- creo el mailbox para la cuenta (si hay error deshacer lo realizado) $username = ""; $configPostfix2 = isPostfixToElastix2(); // in misc.lib.php if ($configPostfix2) { $username = $_POST['address'] . '@' . $domain_name; } else { $username = $_POST['address'] . '.' . $domain_name; } $arrAccount = $pEmail->getAccount($username); if (is_array($arrAccount) && count($arrAccount) > 0) { //YA EXISTE ESA CUENTA $errMsg = _tr('The e-mail address already exists') . ": {$_POST['address']}@{$domain_name}"; return FALSE; } $bReturn = $pEmail->createAccount($domain_name, $_POST['address'], $_POST['password1'], $_POST['quota']); if (!$bReturn) { $errMsg = $pEmail->errMsg; } return $bReturn; }