/**
 * Simulate a message processing and save email into DB
 *
 * @param string Message text
 * @return boolean true on success
 */
function dre_simulate_message($message_text)
{
    global $Settings;
    global $dre_messages, $is_cron_mode, $DB, $localtimenow;
    $content = $message_text;
    dre_msg('<hr /><h3>' . sprintf(T_('Working with message %s:'), '#1') . '</h3>');
    dre_msg(sprintf(T_('Message body: %s'), '<pre style="font-size:10px">' . htmlspecialchars($content) . '</pre>'));
    dre_msg('<b class="green">' . T_('(No MIME decoding is done in simulation mode)') . '</b>');
    // Remove content after terminators
    $content = dre_limit_by_terminators($content);
    dre_msg('<h4>' . T_('Saving the returned email in the database') . '</h4>');
    // Get data of the returned email:
    $email_data = dre_get_email_data($content, $message_text, 'Empty headers');
    dre_msg(T_('Email Address') . ': ' . $email_data['address']);
    dre_msg(T_('Error Type') . ': ' . dre_decode_error_type($email_data['errtype']));
    dre_msg(T_('Error Message') . ': ' . $email_data['errormsg']);
    // Insert a returned email's data into DB:
    return dre_insert_returned_email($email_data);
}
 *
 * {@internal License choice
 * - If you have received this file as part of a package, please find the license.txt file in
 *   the same folder or the closest folder above for complete license terms.
 * - If you have received this file individually (e-g: from http://evocms.cvs.sourceforge.net/)
 *   then you must choose one of the following licenses before using the file:
 *   - GNU General Public License 2 (GPL) - http://www.opensource.org/licenses/gpl-license.php
 *   - Mozilla Public License 1.1 (MPL) - http://www.opensource.org/licenses/mozilla1.1.php
 * }}
 *
 * {@internal Open Source relicensing agreement:
 * }}
 *
 * @package admin
 *
 * @version $Id: _email_sent_details.view.php 349 2011-11-18 11:18:14Z yura $
 */
if (!defined('EVO_MAIN_INIT')) {
    die('Please, do not access this page directly.');
}
global $MailReturn;
$Form = new Form(NULL, 'mail_returns', 'post', 'compact');
$Form->global_icon(T_('Cancel viewing!'), 'close', regenerate_url('blog'));
$Form->begin_form('fform', sprintf(T_('Returned mail ID#%s'), $MailReturn->emret_ID));
$Form->info(T_('Date'), mysql2localedatetime_spans($MailReturn->emret_timestamp, 'Y-m-d', 'H:i:sP'));
$Form->info(T_('Error Type'), dre_decode_error_type($MailReturn->emret_errtype));
$Form->info(T_('Address'), '<pre class="email_log"><span>' . htmlspecialchars($MailReturn->emret_address) . '</span></pre>');
$Form->info(T_('Error'), '<pre class="email_log"><span>' . htmlspecialchars($MailReturn->emret_errormsg) . '</span></pre>');
$Form->info(T_('Headers'), '<pre class="email_log_scroll"><span>' . htmlspecialchars($MailReturn->emret_headers) . '</span></pre>');
$Form->info(T_('Message'), '<pre class="email_log_scroll"><span>' . htmlspecialchars($MailReturn->emret_message) . '</span></pre>');
$Form->end_form();
/**
 * Simulate a message processing and save email into DB
 *
 * @param string Message text
 * @return boolean true on success
 */
function dre_simulate_message($message_text)
{
    global $Settings;
    global $dre_messages, $is_cron_mode, $DB, $localtimenow;
    $content = $message_text;
    dre_msg('<hr /><h3>Processing message:</h3>');
    dre_msg('Message body: <pre style="font-size:10px">' . htmlspecialchars($content) . '</pre>');
    dre_msg('<b class="green">Success</b>');
    // Remove content after terminators
    $content = dre_limit_by_terminators($content);
    dre_msg(sprintf('<h4>Saving the returned email in the database</h4>'));
    // Insert a returned email's data into DB
    if ($returned_email = dre_insert_returned_email($content, $message_text, 'Empty headers')) {
        dre_msg('Error Type: ' . dre_decode_error_type($returned_email['errtype']));
        dre_msg('Error Message: ' . $returned_email['errormsg']);
        return true;
    } else {
        return false;
    }
}