/** * Check if the password is correct without logging in the user * * @param string $uid The username * @param string $password The password * * @return true/false */ public function checkPassword($uid, $password) { if (!function_exists('imap_open')) { OCP\Util::writeLog('user_external', 'ERROR: PHP imap extension is not installed', OCP\Util::ERROR); return false; } // Check if we only want logins from ONE domain and strip the domain part from UID if ($this->domain != '') { $pieces = explode('@', $uid); if (count($pieces) == 1) { $username = $uid . "@" . $this->domain; } elseif (count($pieces) == 2 and $pieces[1] == $this->domain) { $username = $uid; $uid = $pieces[0]; } else { return false; } } else { $username = $uid; } $mbox = @imap_open($this->mailbox, $username, $password, OP_HALFOPEN, 1); imap_errors(); imap_alerts(); if ($mbox !== FALSE) { imap_close($mbox); $uid = mb_strtolower($uid); $this->storeUser($uid); return $uid; } else { return false; } }
/** * @brief Check if the password is correct * @param $uid The username * @param $password The password * @returns true/false * * Check if the password is correct without logging in the user */ public function checkPassword($uid, $password) { $mbox = @imap_open($this->mailbox, $uid, $password); imap_errors(); imap_alerts(); if ($mbox) { imap_close($mbox); return $uid; } else { return false; } }
/** * Authenticate connection * * @param string $username Username * @param string $password Password * * @return \Ddeboer\Imap\Connection * @throws AuthenticationFailedException */ public function authenticate($username, $password) { $resource = @\imap_open($this->getServerString(), $username, $password, null, 1); if (false === $resource) { throw new AuthenticationFailedException($username); } $check = imap_check($resource); $mailbox = $check->Mailbox; $this->connection = substr($mailbox, 0, strpos($mailbox, '}') + 1); // These are necessary to get rid of PHP throwing IMAP errors imap_errors(); imap_alerts(); return new Connection($resource, $this->connection); }
public function open($server, $username, $password, $mailbox, array $flags) { if (!empty($flags)) { $server .= '/' . implode('/', $flags); } $mailbox = '{' . $server . '}' . $mailbox; $this->resource = @imap_open($mailbox, $username, $password); if (!$this->resource) { $error = imap_last_error(); imap_errors(); imap_alerts(); throw new IMAPException($error); } return $this; }
/** * Check if the password is correct without logging in the user * * @param string $uid The username * @param string $password The password * * @return true/false */ public function checkPassword($uid, $password) { if (!function_exists('imap_open')) { OCP\Util::writeLog('user_external', 'ERROR: PHP imap extension is not installed', OCP\Util::ERROR); return false; } $mbox = @imap_open($this->mailbox, $uid, $password, OP_HALFOPEN); imap_errors(); imap_alerts(); if ($mbox !== FALSE) { imap_close($mbox); $this->storeUser($uid); return $uid; } else { return false; } }
function connect() { $this->conn = @imap_open('{' . $this->server . '/notls}', $this->user, $this->pass, null, 1); // Supress alerts imap_alerts(); $errors = imap_errors(); $searchword = 'AUTHENTICATIONFAILED'; $matches = array_filter($errors, function ($var) use($searchword) { return preg_match("/\\b{$searchword}\\b/i", $var); }); if (is_bool($this->conn) || !empty($matches)) { $this->connected = false; return false; } else { $this->connected = true; return true; } }
public function authenticate(array $credentials) { list($username, $password) = $credentials; $loginData = $this->imapLoginModel->getBy(array("username" => $username)); $mbox = imap_open("{localhost:993/ssl/novalidate-cert}INBOX", $username, $password, OP_HALFOPEN | OP_SILENT); imap_alerts(); imap_errors(); if (!$loginData) { throw new \Nette\Security\AuthenticationException('Neznámé jméno uživatele.', self::IDENTITY_NOT_FOUND); } elseif (!$mbox) { throw new \Nette\Security\AuthenticationException('Nesprávné heslo.', self::INVALID_CREDENTIAL); } $identity = $this->buildIdentity($loginData->user_id); $enabled = $identity->getData()["enabled"]; if (!$enabled) { throw new \Nette\Security\AuthenticationException('Tento účet je zablokovaný.', self::INACTIVE); } $this->user->login($identity); }
/** * Authenticate connection * * @param string $username Username * @param string $password Password * * @return Connection * @throws AuthenticationFailedException */ public function authenticate($username, $password) { // Wrap imap_open, which gives notices instead of exceptions set_error_handler(function ($nr, $message) use($username) { throw new AuthenticationFailedException($username, $message); }); $resource = imap_open($this->getServerString(), $username, $password, null, 1, $this->parameters); if (false === $resource) { throw new AuthenticationFailedException($username); } restore_error_handler(); $check = imap_check($resource); $mailbox = $check->Mailbox; $this->connection = substr($mailbox, 0, strpos($mailbox, '}') + 1); // These are necessary to get rid of PHP throwing IMAP errors imap_errors(); imap_alerts(); return new Connection($resource, $this->connection); }
/** Initialize the mailbox connection. The mailbox connection parameters are as follow: * host: Host name of the server hosting the mailbox. Default: localhost. * port: Port of the imap service. Default: 143. * mailbox: Mailbox name. Default: INBOX. * flags: Connection flags. Optionnal. * user: User name. * password: User password. For a detailed list of available flags, please see the PHP documentation for imap_open. The connection to the mailbox is read-only until tested enough. @param $aParams Mailbox connection parameters. @see http://php.net/imap_open */ public function __construct($aParams) { function_exists('imap_open') or burn('ConfigurationException', _WT('The IMAP PHP extension is required by the weeFetchMail class.')); empty($aParams['user']) and burn('InvalidParameterException', _WT('The user name was not provided in the connection parameters.')); empty($aParams['password']) and burn('InvalidParameterException', _WT('The user password was not provided in the connection parameters.')); // Fill in the default values $aParams = $aParams + array('host' => 'localhost', 'port' => 143, 'mailbox' => 'INBOX'); $sConnection = '{' . $aParams['host'] . ':' . $aParams['port']; if (!empty($aParams['flags'])) { $sConnection .= $aParams['flags']; } $sConnection .= '}' . $aParams['mailbox']; $this->rLink = @imap_open($sConnection, $aParams['user'], $aParams['password'], OP_READONLY, 1); // We must clear the errors and alerts or they'll be thrown separately, possibly multiple times. // Despite their names, those functions also clear the errors buffer. imap_alerts(); $a = imap_errors(); // Then we only output the first error from the array we retrieved (usually good enough). $this->rLink === false and burn('UnexpectedValueException', _WT("Couldn't open stream \"%s\" with the following error:\n%s", $sConnection, $a[0])); }
/** * Open the remote mailbox * * @param string|null $extension Extension of the serveur to open (/Inbox, ...) * * @return int|bool */ function open($extension = null) { $port = $this->source->port ? ":" . $this->source->port : ""; $protocole = $this->source->auth_ssl ? "https://" : "http://"; $url = $protocole . $this->source->host . $port; if (!isset($this->_server)) { CAppUI::stepAjax("CPop-error-notInitiated", UI_MSG_ERROR); return false; } $password = $this->source->getPassword(); $server = $this->_server . $extension; $this->_mailbox = @imap_open($server, $this->source->user, $password, 0, 0); //avoid errors reporting imap_errors(); imap_alerts(); if ($this->_mailbox === false) { //CModelObject::warning("IMAP-warning-configuration-unreashable", $this->source->object_class, $this->source->object_id); return false; } $this->_is_open = true; return $this->_mailbox; }
/** Get Status Messages */ function stat() { $r = null; if ($this->_c) { imap_check($this->_c); } $x = imap_alerts(); if (!empty($x)) { $r .= "Alerts:\n " . implode('; ', $x) . "\n"; } $x = imap_errors(); if (!empty($x)) { $r .= "Errors:\n " . implode('; ', $x) . "\n"; } return $r; }
/** * Wrapper function for {@link imap_alerts}. Implodes the array returned by imap_alerts, * (if any) and returns the text. * * @param string $seperator Characters to seperate each alert message. '<br />\n' by default. * @return string|FALSE * @access public * @see imap_alerts * @see errors */ function alerts($seperator = "<br />\n") { $alerts = imap_alerts(); return is_array($alerts) && !empty($alerts) ? implode($seperator, $alerts) : FALSE; }
/** * Connect To the Mail Box */ public function connect() { if (!function_exists('imap_open')) { throw new \Exception('imap_open function must be enabled'); } $this->setMailBox(@imap_open($this->getServer(), $this->getUsername(), $this->getPassword(), OP_SILENT)); $errors = imap_errors(); $alerts = imap_alerts(); if (!$this->getMailBox()) { if (!$errors) { $errors = array(); } if (!$alerts) { $alerts = array(); } throw new \Exception("Error: " . implode('. ', array_merge($errors, $alerts))); } return $this->getMailBox(); }
handleBounce($type, $newsletterID, EZSOFTBOUNCE); break; case EZHARDBOUNCE: handleBounce($type, $newsletterID, EZHARDBOUNCE); break; case EZNOBOUNCE: default: // TODO break; } } else { //do not delete $delete = false; } $imapErrors = imap_errors(); $imapAlerts = imap_alerts(); if ($imapErrors) { $cli->output("\nMAIL ID: {$mailID}"); print_r($imapErrors); } if ($imapAlerts) { $cli->output("\nMAIL ID: {$mailID}"); print_r($imapAlerts); } if ($delete) { imap_delete($mailbox, $i); } } // Close imap connection imap_close($mailbox, CL_EXPUNGE); }
public function close($expunge = true) { imap_alerts(); imap_errors(); imap_close($this->imap, $expunge ? CL_EXPUNGE : 0); }
/** * Wrapper function for {@link imap_alerts}. Implodes the array returned by imap_alerts, * (if any) and returns the text. * * @param bool $handler * How to handle the imap error stack, true by default. If true adds the alerts * to the PEAR_ErrorStack object. If false, returns the imap alert stack. * * @param string $seperator Characters to seperate each alert message. '<br />\n' by default. * @return bool|string * @access public * @see imap_alerts * @see errors * @tutorial http://www.smilingsouls.net/Mail_IMAP?content=Mail_IMAP/alerts */ function alerts($handler = true, $seperator = "<br />\n") { $alerts = imap_alerts(); if (empty($alerts)) { return false; } if ($handler) { foreach ($alerts as $alert) { $this->error->push(Mail_IMAPv2_ERROR, 'notice', null, $alert); } return true; } return implode($seperator, $alerts); }
/** * GET INDIVIDUAL EMAILS * @param [type] $email_id [description] * @return [type] [description] */ public function getEmail($email_id, $msgOnly = TRUE) { $this->_connect(); $email = @imap_fetchstructure($this->imap, $email_id, 0); imap_errors(); imap_alerts(); if (is_object($email)) { switch (strtolower($email->subtype)) { case "plain": $partNum = 1; break; case "alternative": $partNum = 1; break; case "mixed": $partNum = 1.2; break; case "html": $partNum = 1.2; break; } $message = quoted_printable_decode(@imap_fetchbody($this->imap, $email_id, $partNum, FT_PEEK)); imap_errors(); imap_alerts(); if (!$msgOnly) { $overview = @imap_fetch_overview($this->imap, $email_id, 0); imap_errors(); imap_alerts(); // $headers = imap_rfc822_parse_headers(imap_fetchheader($this->imap,$email_id)); switch (strtolower($email->subtype)) { case "plain": $partNum = 1; break; case "alternative": $partNum = 1; break; case "mixed": $partNum = 1.2; break; case "html": $partNum = 1.2; break; } $attachments = $this->getAttachments($email_id); $emailInfo = array('overview' => $overview[0], 'structure' => $email, 'message' => $message, 'attachments' => $attachments); } } else { return false; } $this->_close(); return $msgOnly ? $message : $emailInfo; }
/** * Close IMAP connection */ protected function disconnect() { if ($this->isConnected()) { // Prevent these from throwing notices such as "SECURITY PROBLEM: insecure server advertised" imap_errors(); imap_alerts(); @imap_close($this->imapStream, CL_EXPUNGE); } }
/** * Clear all IMAP notices and warnings */ public function __destruct() { imap_errors(); imap_alerts(); }
public function getErrors() { $errors = imap_errors(); $alerts = imap_alerts(); if (is_array($errors)) { echo "<pre>"; print_r($errors); } if (is_array($alerts)) { echo "<pre>"; print_r($alerts); } }
function processAuthorizeReport() { /** * Check specified mailbox for ARB notifications */ if (!defined('_CRM_PROCESS_AUTHORIZE_REPORT_IMAP_HOST') || _CRM_PROCESS_AUTHORIZE_REPORT_IMAP_HOST == '') { $this->_criticalError('No IMAP server defined'); } if (!defined('_CRM_PROCESS_AUTHORIZE_REPORT_IMAP_USER') || _CRM_PROCESS_AUTHORIZE_REPORT_IMAP_USER == '') { $this->_criticalError('No IMAP username provided'); } if (!defined('_CRM_PROCESS_AUTHORIZE_REPORT_IMAP_PASS') || _CRM_PROCESS_AUTHORIZE_REPORT_IMAP_PASS == '') { $this->_criticalError('No IMAP password provided'); } if (defined('_CRM_PROCESS_AUTHORIZE_REPORT_IMAP_SECURITY')) { $imap_security = '/' . _CRM_PROCESS_AUTHORIZE_REPORT_IMAP_SECURITY . '/novalidate-cert'; } else { $imap_security = ''; } if (defined('_CRM_PROCESS_AUTHORIZE_REPORT_IMAP_PORT') && _CRM_PROCESS_AUTHORIZE_REPORT_IMAP_PORT != '') { $imap_port = ':' . _CRM_PROCESS_AUTHORIZE_REPORT_IMAP_PORT; } elseif ($imap_security) { $imap_port = ':993'; } else { $imap_port = ''; } if (defined('_CRM_PROCESS_AUTHORIZE_REPORT_IMAP_INBOX') && _CRM_PROCESS_AUTHORIZE_REPORT_IMAP_INBOX != '') { $imap_inbox = _CRM_PROCESS_AUTHORIZE_REPORT_IMAP_INBOX; } else { $imap_inbox = 'INBOX'; } // create connection string and connect $conn_str = '{' . _CRM_PROCESS_AUTHORIZE_REPORT_IMAP_HOST . $imap_port . '/imap' . $imap_security . '}' . $imap_inbox; $this->email_conn = @imap_open($conn_str, _CRM_PROCESS_AUTHORIZE_REPORT_IMAP_USER, _CRM_PROCESS_AUTHORIZE_REPORT_IMAP_PASS) or $this->_criticalError('Cannot connect to ' . _CRM_PROCESS_AUTHORIZE_REPORT_IMAP_HOST . ' as ' . _CRM_PROCESS_AUTHORIZE_REPORT_IMAP_USER); // Get list of Automated Recurring Billing messages $msgList = imap_search($this->email_conn, 'UNDELETED SUBJECT "Summary of Automated Recurring Billing"'); if (!$msgList) { // no mesasges. nothing to do. exit; } /** * Get info from CSV files */ foreach ($msgList as $msg_id) { $mailHeader = imap_headerinfo($this->email_conn, $msg_id); $this->_addToSummary(null); // insert blank line. $this->_addToSummary('Processing an ARB email'); $mail_date = date('YmdHis', strtotime($mailHeader->date)); $mail_date = CRM_Utils_Date::isoToMysql($mail_date); // extract the CSV files $attachments = $this->_getAttachmentsData($msg_id); foreach ($attachments as $key => $attachment) { $this->_addAttachment($attachment, $msg_id, $key); $attachment = $this->_csv_to_array($attachment); $attachments[$key] = $attachment; } // process successful.csv if (isset($attachments['successful.csv'])) { $this->_process_csv($attachments['successful.csv'], 'successful.csv', $mail_date); $process_successful = true; } else { $process_successful = false; } // process failed.csv if (isset($attachments['failed.csv'])) { $this->_process_csv($attachments['failed.csv'], 'failed.csv', $mail_date); $process_failed = true; } else { $process_failed = false; } // mark message as processed if ($process_successful && $process_failed) { $this->_addMsgID($msg_id); $this->emails_processed++; } } $this->_addToSummary('Total Authorize.net emails processed: ' . $this->emails_processed); // send summary $this->_sendSummaryEmail(); // get rid of processed messages if (defined('_CRM_PROCESS_AUTHORIZE_REPORT_IMAP_PROCESSED_MAILBOX') && _CRM_PROCESS_AUTHORIZE_REPORT_IMAP_PROCESSED_MAILBOX != '') { $msg_id_list = implode(',', $this->_getMsgIDs()); imap_mail_move($this->email_conn, $msg_id_list, _CRM_PROCESS_AUTHORIZE_REPORT_IMAP_PROCESSED_MAILBOX); } else { foreach ($this->_getMsgIDs() as $id) { imap_delete($this->email_conn, $id); } } if ($this->_debug) { print_r(imap_alerts()); print_r(imap_errors()); } imap_close($this->email_conn); }
/** * Connects to mailserver. If an existing IMAP resource is available, it * will attempt to reuse the connection, updating the mailbox path. * * @param bool test Flag to test connection * @param bool force Force reconnect * @return string "true" on success, "false" or $errorMessage on failure */ function connectMailserver($test = false, $force = false) { global $mod_strings; if (!function_exists("imap_open")) { $GLOBALS['log']->debug('------------------------- IMAP libraries NOT available!!!! die()ing thread.----'); return $mod_strings['LBL_WARN_NO_IMAP']; } imap_errors(); // clearing error stack error_reporting(0); // turn off notices from IMAP // tls::ca::ssl::protocol::novalidate-cert::notls $useSsl = $_REQUEST['ssl'] == 'true' ? true : false; if ($test) { imap_timeout(1, 15); // 60 secs is the default imap_timeout(2, 15); imap_timeout(3, 15); $opts = $this->findOptimumSettings($useSsl); if (isset($opts['good']) && empty($opts['good'])) { return array_pop($opts['err']); } else { $service = $opts['service']; $service = str_replace('foo', '', $service); // foo there to support no-item explodes } } else { $service = $this->getServiceString(); } $connectString = $this->getConnectString($service, $this->mailbox); /* * Try to recycle the current connection to reduce response times */ if (is_resource($this->conn)) { if ($force) { // force disconnect imap_close($this->conn); } if (imap_ping($this->conn)) { // we have a live connection imap_reopen($this->conn, $connectString, CL_EXPUNGE); } } // final test if (!is_resource($this->conn) && !$test) { $this->conn = imap_open($connectString, $this->email_user, $this->email_password, CL_EXPUNGE); } if ($test) { if ($opts == false && !is_resource($this->conn)) { $this->conn = imap_open($connectString, $this->email_user, $this->email_password, CL_EXPUNGE); } $errors = ''; $alerts = ''; $successful = false; if (($errors = imap_last_error()) || ($alerts = imap_alerts())) { if ($errors == 'Mailbox is empty') { // false positive $successful = true; } else { $msg .= $errors; $msg .= '<p>' . $alerts . '<p>'; $msg .= '<p>' . $mod_strings['ERR_TEST_MAILBOX']; } } else { $successful = true; } if ($successful) { if ($this->protocol == 'imap') { $msg .= $mod_strings['LBL_TEST_SUCCESSFUL']; /* $testConnectString = '{'.$this->server_url.':'.$this->port.'/service='.$this->protocol.$service.'}'; if (!is_resource($this->conn)) { $this->conn = imap_open($connectString, $this->email_user, $this->email_password, CL_EXPUNGE); } $list = imap_getmailboxes($this->conn, $testConnectString, "*"); if(isset($_REQUEST['personal']) && $_REQUEST['personal'] == 'true') { $msg .= $mod_strings['LBL_TEST_SUCCESSFUL']; } elseif (is_array($list)) { sort($list); _ppd($boxes); $msg .= '<b>'.$mod_strings['LBL_FOUND_MAILBOXES'].'</b><p>'; foreach ($list as $key => $val) { $mb = imap_utf7_decode(str_replace($testConnectString,'',$val->name)); $msg .= '<a onClick=\'setMailbox(\"'.$mb.'\"); window.close();\'>'; $msg .= $mb; $msg .= '</a><br>'; } } else { $msg .= $errors; $msg .= '<p>'.$mod_strings['ERR_MAILBOX_FAIL'].imap_last_error().'</p>'; $msg .= '<p>'.$mod_strings['ERR_TEST_MAILBOX'].'</p>'; } */ } else { $msg .= $mod_strings['LBL_POP3_SUCCESS']; } } imap_errors(); // collapse error stack imap_close($this->conn); return $msg; } elseif (!is_resource($this->conn)) { return "false"; } else { return "true"; } }
/** * Returns all the imap alert messages that have occurred * @return array */ public function getAlerts() { return imap_alerts(); }
public function checkConnection() { $options = JRequest::getVar('jform'); $mailbox = new MigurMailerMailbox($options); $errors = array(); if ($mailbox->connect()) { $mailbox->close(); } else { $errors[] = JText::_('COM_NEWSLETTER_UNABLE_TO_CONNECT'); $errors[] = $mailbox->getLastError(); if (!$mailbox->protocol->getOption('noValidateCert')) { $mailbox->protocol->setOption('noValidateCert', true); $errors[] = JText::_('COM_NEWSLETTER_TRYING_TO_CONNECT_WITHOUT_CERT'); if ($mailbox->connect()) { $mailbox->close(); $errors[] = JText::_('COM_NEWSLETTER_OK_CHECK_YOUR_CERT'); } else { $errors[] = JText::_('COM_NEWSLETTER_FAILED') . '. ' . $mailbox->getLastError(); } } } if (count($errors) == 0) { $status = 'ok'; } else { $status = ''; foreach ($errors as $error) { $status .= "\n" . $error; } } imap_errors(); imap_alerts(); echo json_encode(array('status' => $status)); jexit(); }
function getErrors() { $return = array(); if ($this->usepear) { //TODO : get some errors from the pear interface? } else { $alerts = imap_alerts(); $errors = imap_errors(); if (!empty($alerts)) { $return = array_merge($return, $alerts); } if (!empty($errors)) { $return = array_merge($return, $errors); } } return $return; }
function get_mail_header($mailbox_handle, $pos) { $header_info = null; $header_info = imap_header($mailbox_handle, $pos); if (!isset($cli)) { $cli = eZCLI::instance(); } if ($imapErrors = imap_errors()) { $cli->error('Found error while trying to read the mail header. Mail pos: $pos', true); print_r($imapErrors); $header_info = null; } if ($imapAlerts = imap_alerts()) { $cli->error('Got alerts while trying to read the mail header. Mail pos: $pos', true); print_r($imapAlerts); } return $header_info; }
$caller_email = isset($caller_email) ? $caller_email : ''; $caller_branch = isset($caller_branch) ? $caller_branch : ''; $caller_city = isset($caller_city) ? $caller_city : ''; $caller_time = isset($caller_time) ? $caller_time : ''; // echo $caller_time.'<br />' ; //echo'start value:'. $startvalue.'<br />'; date_default_timezone_set('Asia/Dili'); $caller_time = date('Y-m-d H:i:s', strtotime(str_replace('-', '/', $caller_time))); $query = "insert into jusdial (`Caller_Name`, `Caller_Requirement`, `Caller_Phone`, " . "`Caller_PhoneExtra`,`Caller_Email`, `Caller_Branch`,`Caller_City`, `Date`) values" . " ('{$caller_name}', '{$caller_requirement}', '{$caller_phone}'," . "'{$caller_phoneextra}','{$caller_email}','{$caller_branch}', '{$caller_city}'," . " '{$caller_time}') on duplicate key update `Caller_Name`='{$caller_name}'" . ",`Caller_Requirement`='{$caller_requirement}'," . "`Caller_PhoneExtra`='{$caller_phoneextra}' , `Date`='{$caller_time}'"; $result = mysql_query($query) or die(mysql_error()); $caller_email = ''; } $startvalue++; } imap_errors(); imap_alerts(); //sending new leads to email $query_new = "select * from jusdial where Date> DATE_SUB(NOW(), INTERVAL 12 HOUR) "; $result_new = mysql_query($query_new) or die(mysql_error()); $day_data = ''; while ($row = mysql_fetch_assoc($result_new)) { $day_data .= implode(' ', $row); $day_data .= '<br /><br />'; } // echo $day_data; $to = "anupam.rekha@satyamtechnologies.net, tribhuvan.nayak@satyamhospital.com"; $headers = "From: care@satyamhospital.com" . "\r\n" . "CC: care@satyamhospital.com"; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n"; if (strip_tags($day_data) != '') { mail($to, 'Satyam Contacts: JustDial ', $day_data, $headers);
/** * Check connections to ALL mailbox servers. * * @return string json */ public function checkMailboxes() { $res = array(); $manager = JModel::getInstance('Mailboxprofiles', 'NewsletterModel'); $mailboxes = $manager->getAllItems(); if (!empty($mailboxes)) { jimport('migur.library.mailer.mailbox'); foreach ($mailboxes as $mailboxSettings) { $text = JText::sprintf('COM_NEWSLETTER_MAINTAINANCE_CHECKMAILBOX', $mailboxSettings->mailbox_profile_name) . '...'; $mailboxSettings = (array) $mailboxSettings; $mailbox = new MigurMailerMailbox($mailboxSettings); $errors = array(); if ($mailbox->connect()) { $mailbox->close(); } else { $errors[] = JText::_('COM_NEWSLETTER_UNABLE_TO_CONNECT'); $errors[] = $mailbox->getLastError(); if (!$mailbox->protocol->getOption('noValidateCert')) { $mailbox->protocol->setOption('noValidateCert', true); $errors[] = JText::_('COM_NEWSLETTER_TRYING_TO_CONNECT_WITHOUT_CERT'); if ($mailbox->connect()) { $mailbox->close(); $errors[] = JText::_('COM_NEWSLETTER_OK_CHECK_YOUR_CERT'); } else { $errors[] = JText::_('COM_NEWSLETTER_FAILED') . '. ' . $mailbox->getLastError(); } } } if (count($errors) > 0) { $text .= '<br/>' . implode('<br/>', $errors); } imap_errors(); imap_alerts(); $res[] = array('text' => $text, 'type' => count($errors) == 0); } } else { $res[] = array('text' => JText::sprintf('COM_NEWSLETTER_MAINTAINANCE_NO_MAILBOXES'), 'type' => false); } // Return data NewsletterHelper::jsonMessage('checkMailboxes', $res); }
function cleanAlertsImap() { $alerts = $errors = ''; $arrAlerts = imap_alerts(); if (is_array($arrAlerts)) { $alerts = implode("<br>", $arrAlerts); } $arrErrors = imap_errors(); if (is_array($arrErrors)) { $errors = implode("<br>", $arrErrors); } if ($alerts != '' && $errors != '') { $text = $alerts . "<br>" . $errors; } else { $text = $alerts . $errors; } return $text; }
/** * @return resource|boolean */ function grr_connect_imap($i_adresse, $i_port, $i_login, $i_pwd, $use_type, $use_ssl, $use_cert, $use_tls, $mode = "normal") { $string1 = ""; if (isset($i_adresse) && !empty($i_adresse)) { $string1 .= "{" . $i_adresse; } else { return $out; } if (isset($i_port) && !empty($i_port)) { $string1 .= ":" . $i_port; } if (isset($use_type)) { $string1 .= $use_type; } if (isset($use_ssl)) { $string1 .= $use_ssl; } if (isset($use_cert)) { $string1 .= $use_cert; } if (isset($use_tls)) { $string1 .= $use_tls; } $string1 .= "}"; // $connect_imap=imap_open($i_string,$i_login,$i_pwd,OP_HALFOPEN); //$string1 = "{pop.free.fr:110/pop3}"; if ($use_type == "/imap") { $connect_imap = @imap_open($string1, $i_login, $i_pwd, OP_HALFOPEN); $string = $string1 . "," . $i_login . "," . $i_pwd . ",OP_HALFOPEN"; } else { $connect_imap = @imap_open($string1, $i_login, $i_pwd); $string = $string1 . "," . $i_login . "," . $i_pwd; } if ($connect_imap) { if ($mode == "diag") { echo "<h2><span style=\"color:green;\">La connexion a réussi !</span></h2>"; @imap_close($connect_imap); return true; } else { return $connect_imap; } } if ($mode == "diag") { echo "<h2><span style=\"color:red;\">La connexion a échoué !</span></h2>"; echo "<span style=\"color:red;\">La chaîne de connexion testée était : {$string}</span>"; $errors = imap_errors(); if (is_array($errors)) { $num = 0; foreach ($errors as $key) { $num++; echo "<br /><span style=\"color:red;\">Erreur {$num} : " . $key . " </span>"; } } $alert = imap_alerts(); if (is_array($alert)) { $num = 0; foreach ($alert as $key) { $num++; echo "<br /><span style=\"color:red;\">Alerte {$num} : " . $key . " </span>"; } } } return false; }