load_funcs('files/model/_file.funcs.php'); } if (!($mbox = dre_connect(true))) { // We couldn't connect to the mail server return 2; // error } // Read messages from server dre_msg(T_('Reading messages from server'), true); $imap_obj = imap_check($mbox); dre_msg(sprintf(T_('Found %d messages'), intval($imap_obj->Nmsgs)), true); if ($imap_obj->Nmsgs == 0) { dre_msg(T_('There are no messages in the mailbox'), true); imap_close($mbox); return 1; // success } // Create posts dre_process_messages($mbox, $imap_obj->Nmsgs, true); if (count($del_cntr) > 0) { // We want to delete processed emails from server imap_expunge($mbox); dre_msg(sprintf(T_('Deleted %d processed message(s) from inbox.'), $del_cntr), true); } imap_close($mbox); // Show reports if ($email_cntr > 0) { dre_msg(sprintf(T_('New emails saved: %d'), $email_cntr), true); } return 1; // success
switch ($action) { case 'test_1': if ($mbox = dre_connect()) { // Close opened connection imap_close($mbox); } break; case 'test_2': if ($mbox = dre_connect()) { // Read messages from server dre_msg('Reading messages from server'); $imap_obj = imap_check($mbox); dre_msg('Found ' . $imap_obj->Nmsgs . ' messages'); if ($imap_obj->Nmsgs > 0) { // We will read only 1 message from server in test mode dre_process_messages($mbox, 1); } else { dre_msg(T_('There are no messages in the mailbox')); } imap_close($mbox); } break; case 'test_3': param('test_error_message', 'raw', ''); if (!empty($test_error_message)) { // Simulate a message processing dre_simulate_message($test_error_message); $repath_test_output = implode("<br />\n", $dre_messages); } break; }