Ejemplo n.º 1
0
/**
 * Get the MIME structure
 *
 * This function gets the structure of a message and stores it in the "message" class.
 * It will return this object for use with all relevant header information and
 * fully parsed into the standard "message" object format.
 */
function mime_structure($bodystructure, $flags = array())
{
    /* Isolate the body structure and remove beginning and end parenthesis. */
    $read = trim(substr($bodystructure, strpos(strtolower($bodystructure), 'bodystructure') + 13));
    $read = trim(substr($read, 0, -1));
    $i = 0;
    $msg = Message::parseStructure($read, $i);
    if (!is_object($msg)) {
        global $color, $mailbox;
        displayPageHeader($color, $mailbox);
        $errormessage = _("SquirrelMail could not decode the bodystructure of the message");
        $errormessage .= '<br />' . _("The bodystructure provided by your IMAP server:") . '<br /><br />';
        $errormessage .= '<pre>' . sm_encode_html_special_chars($read) . '</pre>';
        plain_error_message($errormessage);
        echo '</body></html>';
        exit;
    }
    if (count($flags)) {
        foreach ($flags as $flag) {
            //FIXME: please document why it is we have to check the first char of the flag but we then go ahead and do a full string comparison anyway.  Is this a speed enhancement?  If not, let's keep it simple and just compare the full string and forget the switch block.
            $char = strtoupper($flag[1]);
            switch ($char) {
                case 'S':
                    if (strtolower($flag) == '\\seen') {
                        $msg->is_seen = true;
                    }
                    break;
                case 'A':
                    if (strtolower($flag) == '\\answered') {
                        $msg->is_answered = true;
                    }
                    break;
                case 'D':
                    if (strtolower($flag) == '\\deleted') {
                        $msg->is_deleted = true;
                    }
                    break;
                case 'F':
                    if (strtolower($flag) == '\\flagged') {
                        $msg->is_flagged = true;
                    } else {
                        if (strtolower($flag) == '$forwarded') {
                            $msg->is_forwarded = true;
                        }
                    }
                    break;
                case 'M':
                    if (strtolower($flag) == '$mdnsent') {
                        $msg->is_mdnsent = true;
                    }
                    break;
                default:
                    break;
            }
        }
    }
    //    listEntities($msg);
    return $msg;
}
Ejemplo n.º 2
0
/**
 * Get the MIME structure
 *
 * This function gets the structure of a message and stores it in the "message" class.
 * It will return this object for use with all relevant header information and
 * fully parsed into the standard "message" object format.
 */
function mime_structure($bodystructure, $flags = array())
{
    /* Isolate the body structure and remove beginning and end parenthesis. */
    $read = trim(substr($bodystructure, strpos(strtolower($bodystructure), 'bodystructure') + 13));
    $read = trim(substr($read, 0, -1));
    $i = 0;
    $msg = Message::parseStructure($read, $i);
    if (!is_object($msg)) {
        include_once SM_PATH . 'functions/display_messages.php';
        global $color, $mailbox;
        /* removed urldecode because $_GET is auto urldecoded ??? */
        displayPageHeader($color, $mailbox);
        echo "<body text=\"{$color['8']}\" bgcolor=\"{$color['4']}\" link=\"{$color['7']}\" vlink=\"{$color['7']}\" alink=\"{$color['7']}\">\n\n" . '<center>';
        $errormessage = _("SquirrelMail could not decode the bodystructure of the message");
        $errormessage .= '<br />' . _("The bodystructure provided by your IMAP server:") . '<br /><br />';
        $errormessage .= '<table><tr><td>' . htmlspecialchars($read) . '</td></tr></table>';
        plain_error_message($errormessage, $color);
        echo '</body></html>';
        exit;
    }
    if (count($flags)) {
        foreach ($flags as $flag) {
            $char = strtoupper($flag[1]);
            switch ($char) {
                case 'S':
                    if (strtolower($flag) == '\\seen') {
                        $msg->is_seen = true;
                    }
                    break;
                case 'A':
                    if (strtolower($flag) == '\\answered') {
                        $msg->is_answered = true;
                    }
                    break;
                case 'D':
                    if (strtolower($flag) == '\\deleted') {
                        $msg->is_deleted = true;
                    }
                    break;
                case 'F':
                    if (strtolower($flag) == '\\flagged') {
                        $msg->is_flagged = true;
                    }
                    break;
                case 'M':
                    if (strtolower($flag) == '$mdnsent') {
                        $msg->is_mdnsent = true;
                    }
                    break;
                default:
                    break;
            }
        }
    }
    //    listEntities($msg);
    return $msg;
}
Ejemplo n.º 3
0
    $a['BackendID'] = $backend->bnum;
    $a['BackendSource'] = $backend->sname;
    $a['BackendWritable'] = $backend->writeable;
    $a['Addresses'] = array();
    // don't do address lookup if we are not viewing that backend
    //
    if ($backend->bnum == $current_backend) {
        $alist = $abook->list_addr($backend->bnum);
        /* check return (array with data or boolean false) */
        if (is_array($alist)) {
            usort($alist, 'alistcmp');
            $a['Addresses'] = formatAddressList($alist);
            $addresses[$backend->bnum] = $a;
        } else {
            // list_addr() returns boolean
            plain_error_message(nl2br(sm_encode_html_special_chars($abook->error)));
        }
    } else {
        $addresses[$backend->bnum] = $a;
    }
}
$current_page_args = array('abook_sort_order' => $abook_sort_order, 'new_bnum' => $current_backend, 'page_number' => $page_number);
// note that plugins can add to $current_page_args as well as
// filter the address list
//
$temp = array(&$addresses, &$current_backend, &$page_number, &$current_page_args);
do_hook('abook_list_filter', $temp);
// NOTE to address book backend authors and plugin authors: if a backend does
//      pagination (which might be more efficient), it needs to place a key
//      in every address listing it returns called "paginated", whose value
//      should evaluate to boolean TRUE.  However, if a plugin will also be
require_once SM_PATH . 'functions/global.php';
require_once SM_PATH . 'functions/imap.php';
require_once SM_PATH . 'functions/display_messages.php';
/* globals */
sqgetGlobalVar('key', $key, SQ_COOKIE);
sqgetGlobalVar('username', $username, SQ_SESSION);
sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION);
sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION);
sqgetGlobalVar('orig', $orig, SQ_POST);
sqgetGlobalVar('old_name', $old_name, SQ_POST);
sqgetGlobalVar('new_name', $new_name, SQ_POST);
/* end globals */
$new_name = trim($new_name);
if (substr_count($new_name, '"') || substr_count($new_name, "\\") || substr_count($new_name, $delimiter) || $new_name == '') {
    displayPageHeader($color, 'None');
    plain_error_message(_("Illegal folder name. Please select a different name.") . '<br /><a href="../src/folders.php">' . _("Click here to go back") . '</a>.', $color);
    exit;
}
$orig = imap_utf7_encode_local($orig);
$old_name = imap_utf7_encode_local($old_name);
$new_name = imap_utf7_encode_local($new_name);
if ($old_name != $new_name) {
    $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
    if (strpos($orig, $delimiter)) {
        $old_dir = substr($orig, 0, strrpos($orig, $delimiter));
    } else {
        $old_dir = '';
    }
    if ($old_dir != '') {
        $newone = $old_dir . $delimiter . $new_name;
    } else {
Ejemplo n.º 5
0
}
/* =================================================================== *
 * The following is only executed on a GET request, or on a POST when  *
 * a user is added, or when "delete" or "modify" was successful.       *
 * =================================================================== */
/* Display error messages */
if (!empty($formerror)) {
    echo html_tag('table', html_tag('tr', html_tag('td', "\n" . '<br /><strong><font color="' . $color[2] . '">' . _("ERROR") . ': ' . htmlspecialchars($formerror) . '</font></strong>' . "\n", 'center')), 'center', '', 'width="100%"');
}
/* Display the address management part */
if ($showaddrlist) {
    /* Get and sort address list */
    $alist = $abook->list_addr();
    if (!is_array($alist)) {
        $abook->error = htmlspecialchars($abook->error);
        plain_error_message($abook->error, $color);
        exit;
    }
    usort($alist, 'alistcmp');
    // filter listing as needed
    $hook_return = do_hook_function('abook_list_filter', $alist);
    if (!empty($hook_return)) {
        $alist = $hook_return;
    }
    $prevbackend = -1;
    $headerprinted = false;
    $compose_to_in_new_window_javascript = ' onclick="var send_to = \'\'; var f = document.forms.length; var i = 0; var grab_next_hidden = \'\'; while (i < f) { var e = document.forms[i].elements.length; var j = 0; while (j < e) { if (document.forms[i].elements[j].type == \'checkbox\' && document.forms[i].elements[j].checked) { var pos = document.forms[i].elements[j].value.indexOf(\':\'); if (pos >= 1) { grab_next_hidden = document.forms[i].elements[j].value; } } else if (document.forms[i].elements[j].type == \'hidden\' && grab_next_hidden == document.forms[i].elements[j].name) { if (send_to != \'\') { send_to += \', \'; } send_to += document.forms[i].elements[j].value; } j++; } i++; } if (send_to != \'\') { comp_in_new(\'' . $base_uri . 'src/compose.php?send_to=\' + send_to); } return false;"';
    echo html_tag('div', '<a href="#AddAddress">' . _("Add address") . '</a>', 'center') . "\n";
    /* List addresses */
    if (count($alist) > 0) {
        echo addForm($form_url, 'post', 'address_book_form');
Ejemplo n.º 6
0
/**
 * Given a list of folder names, unsubscribes from each of them.
 */
function folders_unsubscribe($imapConnection, $folder_names)
{
    global $color, $oTemplate;
    if (count($folder_names) == 0 || $folder_names[0] == '') {
        plain_error_message(_("You have not selected a folder to unsubscribe. Please do so.") . '<br /><a href="../src/folders.php">' . _("Click here to go back") . '</a>.', $color);
        sqimap_logout($imapConnection);
        $oTemplate->display('footer.tpl');
        exit;
    }
    foreach ($folder_names as $folder_name) {
        sqimap_unsubscribe($imapConnection, $folder_name);
    }
    return;
}
Ejemplo n.º 7
0
function SendMDN($mailbox, $passed_id, $sender, $message, $imapConnection)
{
    global $username, $attachment_dir, $color, $default_move_to_sent, $version, $attachments, $squirrelmail_language, $default_charset, $languages, $useSendmail, $domain, $sent_folder, $popuser, $data_dir;
    sqgetGlobalVar('SERVER_NAME', $SERVER_NAME, SQ_SERVER);
    $header = $message->rfc822_header;
    $hashed_attachment_dir = getHashedDir($username, $attachment_dir);
    $rfc822_header = new Rfc822Header();
    $content_type = new ContentType('multipart/report');
    $content_type->properties['report-type'] = 'disposition-notification';
    set_my_charset();
    if ($default_charset) {
        $content_type->properties['charset'] = $default_charset;
    }
    $rfc822_header->content_type = $content_type;
    $rfc822_header->to[] = $header->dnt;
    $rfc822_header->subject = _("Read:") . ' ' . decodeHeader($header->subject, true, false);
    // FIXME: use identity.php from SM 1.5. Change this also in compose.php
    $reply_to = '';
    if (isset($identity) && $identity != 'default') {
        $from_mail = getPref($data_dir, $username, 'email_address' . $identity);
        $full_name = getPref($data_dir, $username, 'full_name' . $identity);
        $from_addr = '"' . $full_name . '" <' . $from_mail . '>';
        $reply_to = getPref($data_dir, $username, 'reply_to' . $identity);
    } else {
        $from_mail = getPref($data_dir, $username, 'email_address');
        $full_name = getPref($data_dir, $username, 'full_name');
        $from_addr = '"' . $full_name . '" <' . $from_mail . '>';
        $reply_to = getPref($data_dir, $username, 'reply_to');
    }
    // Patch #793504 Return Receipt Failing with <@> from Tim Craig (burny_md)
    // This merely comes from compose.php and only happens when there is no
    // email_addr specified in user's identity (which is the startup config)
    if (ereg("^([^@%/]+)[@%/](.+)\$", $username, $usernamedata)) {
        $popuser = $usernamedata[1];
        $domain = $usernamedata[2];
        unset($usernamedata);
    } else {
        $popuser = $username;
    }
    if (!$from_mail) {
        $from_mail = "{$popuser}@{$domain}";
        $from_addr = $from_mail;
    }
    $rfc822_header->from = $rfc822_header->parseAddress($from_addr, true);
    if ($reply_to) {
        $rfc822_header->reply_to = $rfc822_header->parseAddress($reply_to, true);
    }
    // part 1 (RFC2298)
    $senton = getLongDateString($header->date, $header->date_unparsed);
    $to_array = $header->to;
    $to = '';
    foreach ($to_array as $line) {
        $to .= ' ' . $line->getAddress();
    }
    $now = getLongDateString(time());
    set_my_charset();
    $body = _("Your message") . "\r\n\r\n" . "\t" . _("To") . ': ' . decodeHeader($to, false, false, true) . "\r\n" . "\t" . _("Subject") . ': ' . decodeHeader($header->subject, false, false, true) . "\r\n" . "\t" . _("Sent") . ': ' . $senton . "\r\n" . "\r\n" . sprintf(_("Was displayed on %s"), $now);
    $special_encoding = '';
    if (isset($languages[$squirrelmail_language]['XTRA_CODE']) && function_exists($languages[$squirrelmail_language]['XTRA_CODE'])) {
        $body = $languages[$squirrelmail_language]['XTRA_CODE']('encode', $body);
        if (strtolower($default_charset) == 'iso-2022-jp') {
            if (mb_detect_encoding($body) == 'ASCII') {
                $special_encoding = '8bit';
            } else {
                $body = mb_convert_encoding($body, 'JIS');
                $special_encoding = '7bit';
            }
        }
    } elseif (sq_is8bit($body)) {
        // detect 8bit symbols added by translations
        $special_encoding = '8bit';
    }
    $part1 = new Message();
    $part1->setBody($body);
    $mime_header = new MessageHeader();
    $mime_header->type0 = 'text';
    $mime_header->type1 = 'plain';
    if ($special_encoding) {
        $mime_header->encoding = $special_encoding;
    } else {
        $mime_header->encoding = '7bit';
    }
    if ($default_charset) {
        $mime_header->parameters['charset'] = $default_charset;
    }
    $part1->mime_header = $mime_header;
    // part2  (RFC2298)
    $original_recipient = $to;
    $original_message_id = $header->message_id;
    $report = "Reporting-UA : {$SERVER_NAME} ; SquirrelMail (version {$version}) \r\n";
    if ($original_recipient != '') {
        $report .= "Original-Recipient : {$original_recipient}\r\n";
    }
    $final_recipient = $sender;
    $report .= "Final-Recipient: rfc822; {$final_recipient}\r\n" . "Original-Message-ID : {$original_message_id}\r\n" . "Disposition: manual-action/MDN-sent-manually; displayed\r\n";
    $part2 = new Message();
    $part2->setBody($report);
    $mime_header = new MessageHeader();
    $mime_header->type0 = 'message';
    $mime_header->type1 = 'disposition-notification';
    $mime_header->encoding = '7bit';
    $part2->mime_header = $mime_header;
    $composeMessage = new Message();
    $composeMessage->rfc822_header = $rfc822_header;
    $composeMessage->addEntity($part1);
    $composeMessage->addEntity($part2);
    if ($useSendmail) {
        require_once SM_PATH . 'class/deliver/Deliver_SendMail.class.php';
        global $sendmail_path, $sendmail_args;
        // Check for outdated configuration
        if (!isset($sendmail_args)) {
            if ($sendmail_path == '/var/qmail/bin/qmail-inject') {
                $sendmail_args = '';
            } else {
                $sendmail_args = '-i -t';
            }
        }
        $deliver = new Deliver_SendMail(array('sendmail_args' => $sendmail_args));
        $stream = $deliver->initStream($composeMessage, $sendmail_path);
    } else {
        require_once SM_PATH . 'class/deliver/Deliver_SMTP.class.php';
        $deliver = new Deliver_SMTP();
        global $smtpServerAddress, $smtpPort, $pop_before_smtp, $pop_before_smtp_host;
        $authPop = isset($pop_before_smtp) && $pop_before_smtp ? true : false;
        $user = '';
        $pass = '';
        if (empty($pop_before_smtp_host)) {
            $pop_before_smtp_host = $smtpServerAddress;
        }
        get_smtp_user($user, $pass);
        $stream = $deliver->initStream($composeMessage, $domain, 0, $smtpServerAddress, $smtpPort, $user, $pass, $authPop, $pop_before_smtp_host);
    }
    $success = false;
    if ($stream) {
        $deliver->mail($composeMessage, $stream);
        $success = $deliver->finalizeStream($stream);
    }
    if (!$success) {
        $msg = _("Message not sent.") . ' ' . _("Server replied:") . "\n<blockquote>\n" . $deliver->dlv_msg . '<br />' . $deliver->dlv_ret_nr . ' ' . $deliver->dlv_server_msg . "</blockquote>\n\n";
        require_once SM_PATH . 'functions/display_messages.php';
        plain_error_message($msg, $color);
    } else {
        unset($deliver);
        // copy message to sent folder
        $move_to_sent = getPref($data_dir, $username, 'move_to_sent');
        if (isset($default_move_to_sent) && $default_move_to_sent != 0) {
            $svr_allow_sent = true;
        } else {
            $svr_allow_sent = false;
        }
        if (isset($sent_folder) && ($sent_folder != '' || $sent_folder != 'none') && sqimap_mailbox_exists($imapConnection, $sent_folder)) {
            $fld_sent = true;
        } else {
            $fld_sent = false;
        }
        if (isset($move_to_sent) && $move_to_sent != 0 || !isset($move_to_sent)) {
            $lcl_allow_sent = true;
        } else {
            $lcl_allow_sent = false;
        }
        if ($fld_sent && $svr_allow_sent && !$lcl_allow_sent || $fld_sent && $lcl_allow_sent) {
            require_once SM_PATH . 'class/deliver/Deliver_IMAP.class.php';
            $imap_deliver = new Deliver_IMAP();
            $imap_deliver->mail($composeMessage, $imapConnection, 0, 0, $imapConnection, $sent_folder);
            unset($imap_deliver);
        }
    }
    return $success;
}
Ejemplo n.º 8
0
function SendMDN($mailbox, $passed_id, $message, $imapConnection)
{
    global $squirrelmail_language, $default_charset, $default_move_to_sent, $languages, $useSendmail, $domain, $sent_folder, $username, $data_dir;
    sqgetGlobalVar('SERVER_NAME', $SERVER_NAME, SQ_SERVER);
    $header = $message->rfc822_header;
    $rfc822_header = new Rfc822Header();
    $content_type = new ContentType('multipart/report');
    $content_type->properties['report-type'] = 'disposition-notification';
    set_my_charset();
    if ($default_charset) {
        $content_type->properties['charset'] = $default_charset;
    }
    $rfc822_header->content_type = $content_type;
    $rfc822_header->to[] = $header->dnt;
    $rfc822_header->subject = _("Read:") . ' ' . decodeHeader($header->subject, true, false);
    $idents = get_identities();
    $needles = array();
    if ($header->to) {
        foreach ($header->to as $message_to) {
            $needles[] = $message_to->mailbox . '@' . $message_to->host;
        }
    }
    $identity = find_identity($needles);
    $from_addr = build_from_header($identity);
    $reply_to = isset($idents[$identity]['reply_to']) ? $idents[$identity]['reply_to'] : '';
    // FIXME: this must actually be the envelope address of the orginal message,
    // but do we have that information? For now the first identity is our best guess.
    $final_recipient = $idents[0]['email_address'];
    $rfc822_header->from = $rfc822_header->parseAddress($from_addr, true);
    if ($reply_to) {
        $rfc822_header->reply_to = $rfc822_header->parseAddress($reply_to, true);
    }
    // part 1 (RFC2298)
    $senton = getLongDateString($header->date, $header->date_unparsed);
    $to_array = $header->to;
    $to = '';
    foreach ($to_array as $line) {
        $to .= ' ' . $line->getAddress();
    }
    $now = getLongDateString(time());
    set_my_charset();
    $body = _("Your message") . "\r\n\r\n" . "\t" . _("To") . ': ' . decodeHeader($to, false, false) . "\r\n" . "\t" . _("Subject") . ': ' . decodeHeader($header->subject, false, false) . "\r\n" . "\t" . _("Sent") . ': ' . $senton . "\r\n" . "\r\n" . sprintf(_("Was displayed on %s"), $now);
    $special_encoding = '';
    if (isset($languages[$squirrelmail_language]['XTRA_CODE']) && function_exists($languages[$squirrelmail_language]['XTRA_CODE'] . '_encode')) {
        $body = call_user_func($languages[$squirrelmail_language]['XTRA_CODE'] . '_encode', $body);
        if (strtolower($default_charset) == 'iso-2022-jp') {
            if (mb_detect_encoding($body) == 'ASCII') {
                $special_encoding = '8bit';
            } else {
                $body = mb_convert_encoding($body, 'JIS');
                $special_encoding = '7bit';
            }
        }
    } elseif (sq_is8bit($body)) {
        $special_encoding = '8bit';
    }
    $part1 = new Message();
    $part1->setBody($body);
    $mime_header = new MessageHeader();
    $mime_header->type0 = 'text';
    $mime_header->type1 = 'plain';
    if ($special_encoding) {
        $mime_header->encoding = $special_encoding;
    } else {
        $mime_header->encoding = '7bit';
    }
    if ($default_charset) {
        $mime_header->parameters['charset'] = $default_charset;
    }
    $part1->mime_header = $mime_header;
    // part2  (RFC2298)
    $original_recipient = $to;
    $original_message_id = $header->message_id;
    $report = "Reporting-UA : {$SERVER_NAME} ; SquirrelMail (version " . SM_VERSION . ") \r\n";
    if ($original_recipient != '') {
        $report .= "Original-Recipient : {$original_recipient}\r\n";
    }
    $report .= "Final-Recipient: rfc822; {$final_recipient}\r\n" . "Original-Message-ID : {$original_message_id}\r\n" . "Disposition: manual-action/MDN-sent-manually; displayed\r\n";
    $part2 = new Message();
    $part2->setBody($report);
    $mime_header = new MessageHeader();
    $mime_header->type0 = 'message';
    $mime_header->type1 = 'disposition-notification';
    $mime_header->encoding = '7bit';
    $part2->mime_header = $mime_header;
    $composeMessage = new Message();
    $composeMessage->rfc822_header = $rfc822_header;
    $composeMessage->addEntity($part1);
    $composeMessage->addEntity($part2);
    if ($useSendmail) {
        require_once SM_PATH . 'class/deliver/Deliver_SendMail.class.php';
        global $sendmail_path, $sendmail_args;
        // Check for outdated configuration
        if (!isset($sendmail_args)) {
            if ($sendmail_path == '/var/qmail/bin/qmail-inject') {
                $sendmail_args = '';
            } else {
                $sendmail_args = '-i -t';
            }
        }
        $deliver = new Deliver_SendMail(array('sendmail_args' => $sendmail_args));
        $stream = $deliver->initStream($composeMessage, $sendmail_path);
    } else {
        require_once SM_PATH . 'class/deliver/Deliver_SMTP.class.php';
        $deliver = new Deliver_SMTP();
        global $smtpServerAddress, $smtpPort, $pop_before_smtp, $pop_before_smtp_host;
        $authPop = isset($pop_before_smtp) && $pop_before_smtp ? true : false;
        if (empty($pop_before_smtp_host)) {
            $pop_before_smtp_host = $smtpServerAddress;
        }
        get_smtp_user($user, $pass);
        $stream = $deliver->initStream($composeMessage, $domain, 0, $smtpServerAddress, $smtpPort, $user, $pass, $authPop, $pop_before_smtp_host);
    }
    $success = false;
    if ($stream) {
        $deliver->mail($composeMessage, $stream);
        $success = $deliver->finalizeStream($stream);
    }
    if (!$success) {
        $msg = _("Message not sent.") . "\n" . $deliver->dlv_msg;
        if (!empty($deliver->dlv_server_msg)) {
            $msg .= "\n" . _("Server replied:") . ' ' . $deliver->dlv_ret_nr . ' ' . nl2br(sm_encode_html_special_chars($deliver->dlv_server_msg));
        }
        plain_error_message($msg);
    } else {
        unset($deliver);
        // move to sent folder
        //
        $move_to_sent = getPref($data_dir, $username, 'move_to_sent');
        if (isset($default_move_to_sent) && $default_move_to_sent != 0) {
            $svr_allow_sent = true;
        } else {
            $svr_allow_sent = false;
        }
        if (isset($sent_folder) && ($sent_folder != '' || $sent_folder != 'none') && sqimap_mailbox_exists($imapConnection, $sent_folder)) {
            $fld_sent = true;
        } else {
            $fld_sent = false;
        }
        if (isset($move_to_sent) && $move_to_sent != 0 || !isset($move_to_sent)) {
            $lcl_allow_sent = true;
        } else {
            $lcl_allow_sent = false;
        }
        if ($fld_sent && $svr_allow_sent && !$lcl_allow_sent || $fld_sent && $lcl_allow_sent) {
            $save_reply_with_orig = getPref($data_dir, $username, 'save_reply_with_orig');
            if ($save_reply_with_orig) {
                $sent_folder = $mailbox;
            }
            require_once SM_PATH . 'class/deliver/Deliver_IMAP.class.php';
            $imap_deliver = new Deliver_IMAP();
            $imap_deliver->mail($composeMessage, $imapConnection, 0, 0, $imapConnection, $sent_folder);
            unset($imap_deliver);
        }
    }
    return $success;
}
Ejemplo n.º 9
0
 * This is a standard Squirrelmail-1.2 API for plugins.
 *
 * @version $Id: bug_report.php 13537 2009-04-13 16:52:57Z jervfors $
 * @package plugins
 * @subpackage bug_report
 */
/**
 * @ignore
 */
define('SM_PATH', '../../');
require_once SM_PATH . 'include/validate.php';
// if this plugin is not enabled, don't continue
//
global $plugins, $color;
if (!in_array('bug_report', $plugins)) {
    plain_error_message(_("Plugin is not enabled"), $color);
    exit;
}
/* load sqimap_get_user_server() */
include_once SM_PATH . 'functions/imap_general.php';
// loading form functions
require_once SM_PATH . 'functions/forms.php';
displayPageHeader($color, 'None');
function Show_Array($array)
{
    $str = '';
    foreach ($array as $key => $value) {
        if ($key != 0 || $value != '') {
            $str .= "    * {$key} = {$value}\n";
        }
    }
Ejemplo n.º 10
0
/**
 * This function builds an array with all the information about
 * the options available to the user, and returns it. The options
 * are grouped by the groups in which they are displayed.
 * For each option, the following information is stored:
 * - name: the internal (variable) name
 * - caption: the description of the option in the UI
 * - type: one of SMOPT_TYPE_*
 * - refresh: one of SMOPT_REFRESH_*
 * - size: one of SMOPT_SIZE_*
 * - save: the name of a function to call when saving this option
 * @return array all option information
 */
function load_optpage_data_personal()
{
    global $data_dir, $username, $edit_identity, $edit_name, $full_name, $reply_to, $email_address, $signature, $tzChangeAllowed, $color;
    /* Set the values of some global variables. */
    $full_name = getPref($data_dir, $username, 'full_name');
    $reply_to = getPref($data_dir, $username, 'reply_to');
    $email_address = getPref($data_dir, $username, 'email_address');
    $signature = getSig($data_dir, $username, 'g');
    /* Build a simple array into which we will build options. */
    $optgrps = array();
    $optvals = array();
    /******************************************************/
    /* LOAD EACH GROUP OF OPTIONS INTO THE OPTIONS ARRAY. */
    /******************************************************/
    /*** Load the Contact Information Options into the array ***/
    $optgrps[SMOPT_GRP_CONTACT] = _("Name and Address Options");
    $optvals[SMOPT_GRP_CONTACT] = array();
    /* Build a simple array into which we will build options. */
    $optvals = array();
    if (!isset($edit_identity)) {
        $edit_identity = TRUE;
    }
    if ($edit_identity || $edit_name) {
        $optvals[SMOPT_GRP_CONTACT][] = array('name' => 'full_name', 'caption' => _("Full Name"), 'type' => SMOPT_TYPE_STRING, 'refresh' => SMOPT_REFRESH_NONE, 'size' => SMOPT_SIZE_HUGE);
    } else {
        $optvals[SMOPT_GRP_CONTACT][] = array('name' => 'full_name', 'caption' => _("Full Name"), 'type' => SMOPT_TYPE_COMMENT, 'refresh' => SMOPT_REFRESH_NONE, 'comment' => $full_name);
    }
    if ($edit_identity) {
        $optvals[SMOPT_GRP_CONTACT][] = array('name' => 'email_address', 'caption' => _("E-mail Address"), 'type' => SMOPT_TYPE_STRING, 'refresh' => SMOPT_REFRESH_NONE, 'size' => SMOPT_SIZE_HUGE);
    } else {
        $optvals[SMOPT_GRP_CONTACT][] = array('name' => 'email_address', 'caption' => _("E-mail Address"), 'type' => SMOPT_TYPE_COMMENT, 'refresh' => SMOPT_REFRESH_NONE, 'comment' => $email_address);
    }
    $optvals[SMOPT_GRP_CONTACT][] = array('name' => 'reply_to', 'caption' => _("Reply To"), 'type' => SMOPT_TYPE_STRING, 'refresh' => SMOPT_REFRESH_NONE, 'size' => SMOPT_SIZE_HUGE);
    $optvals[SMOPT_GRP_CONTACT][] = array('name' => 'signature', 'caption' => _("Signature"), 'type' => SMOPT_TYPE_TEXTAREA, 'refresh' => SMOPT_REFRESH_NONE, 'size' => SMOPT_SIZE_MEDIUM, 'save' => 'save_option_signature');
    if ($edit_identity) {
        $identities_link_value = '<a href="options_identities.php">' . _("Edit Advanced Identities") . '</a> ' . _("(discards changes made on this form so far)");
        $optvals[SMOPT_GRP_CONTACT][] = array('name' => 'identities_link', 'caption' => _("Multiple Identities"), 'type' => SMOPT_TYPE_COMMENT, 'refresh' => SMOPT_REFRESH_NONE, 'comment' => $identities_link_value);
    }
    if ($tzChangeAllowed) {
        $TZ_ARRAY[SMPREF_NONE] = _("Same as server");
        $tzfile = SM_PATH . 'locale/timezones.cfg';
        if (!is_readable($tzfile) or !($fd = fopen($tzfile, 'r'))) {
            $message = _("Error opening timezone config, contact administrator.");
        }
        // TODO: make error user friendly
        if (isset($message)) {
            plain_error_message($message, $color);
            exit;
        }
        while (!feof($fd)) {
            $zone = fgets($fd, 1024);
            if ($zone) {
                $zone = trim($zone);
                $TZ_ARRAY[$zone] = $zone;
            }
        }
        fclose($fd);
        $optgrps[SMOPT_GRP_TZ] = _("Timezone Options");
        $optvals[SMOPT_GRP_TZ] = array();
        $optvals[SMOPT_GRP_TZ][] = array('name' => 'timezone', 'caption' => _("Your current timezone"), 'type' => SMOPT_TYPE_STRLIST, 'refresh' => SMOPT_REFRESH_NONE, 'posvals' => $TZ_ARRAY);
    }
    /*** Load the Reply Citation Options into the array ***/
    $optgrps[SMOPT_GRP_REPLY] = _("Reply Citation Options");
    $optvals[SMOPT_GRP_REPLY] = array();
    $optvals[SMOPT_GRP_REPLY][] = array('name' => 'reply_citation_style', 'caption' => _("Reply Citation Style"), 'type' => SMOPT_TYPE_STRLIST, 'refresh' => SMOPT_REFRESH_NONE, 'posvals' => array(SMPREF_NONE => _("No Citation"), 'author_said' => _("AUTHOR Wrote"), 'date_time_author' => _("On DATE, AUTHOR Wrote"), 'quote_who' => _("Quote Who XML"), 'user-defined' => _("User-Defined")));
    $optvals[SMOPT_GRP_REPLY][] = array('name' => 'reply_citation_start', 'caption' => _("User-Defined Citation Start"), 'type' => SMOPT_TYPE_STRING, 'refresh' => SMOPT_REFRESH_NONE, 'size' => SMOPT_SIZE_MEDIUM);
    $optvals[SMOPT_GRP_REPLY][] = array('name' => 'reply_citation_end', 'caption' => _("User-Defined Citation End"), 'type' => SMOPT_TYPE_STRING, 'refresh' => SMOPT_REFRESH_NONE, 'size' => SMOPT_SIZE_MEDIUM);
    /*** Load the Signature Options into the array ***/
    $optgrps[SMOPT_GRP_SIG] = _("Signature Options");
    $optvals[SMOPT_GRP_SIG] = array();
    $optvals[SMOPT_GRP_SIG][] = array('name' => 'use_signature', 'caption' => _("Use Signature"), 'type' => SMOPT_TYPE_BOOLEAN, 'refresh' => SMOPT_REFRESH_NONE);
    $optvals[SMOPT_GRP_SIG][] = array('name' => 'prefix_sig', 'caption' => _("Prefix Signature with '-- ' Line"), 'type' => SMOPT_TYPE_BOOLEAN, 'refresh' => SMOPT_REFRESH_NONE);
    /* Assemble all this together and return it as our result. */
    $result = array('grps' => $optgrps, 'vals' => $optvals);
    return $result;
}
Ejemplo n.º 11
0
/**
 * Validate Plugin Setup Utility
 *
 * Checks a plugin to see if the user has installed it 
 * correctly by checking for the existence of the given
 * files (all relative from the plugin's directory)
 *
 * @param string $pluginName The name of the plugin as
 *                           it is known to SquirrelMail, 
 *                           that is, it is the name
 *                           of the plugin directory.
 * @param array $configFiles An array of any files that the
 *                           user should have set up for 
 *                           this plugin, for example:
 *                             array('config.php') 
 *                           or: 
 *                             array('data/config.php', 'data/admins.php')
 *                           where all files will be 
 *                           referenced from the plugin's
 *                           main directory.
 *                           It is also possible to give a 
 *                           full/direct path to a 
 *                           configuration file by placing 
 *                           a forward slash at the 
 *                           beginning of the file:
 *                             array('/var/lib/squirrelmail/config/myplugin.conf')
 * @param boolean $return_errors When true, any errors encountered
 *                               will cause this function to return
 *                               either FALSE or a string describing
 *                               the error; otherwise, errors are
 *                               handled herein by showing an error 
 *                               to the user and exiting (OPTIONAL; 
 *                               default is FALSE).
 *
 * @return mixed If no errors are found, TRUE is returned; if an error
 *               was found and $return_errors is TRUE, either FALSE or 
 *               a string describing the error is returned.  If $return_errors
 *               is FALSE and an error is found, this function will never
 *               return.
 *
 */
function check_plugin_setup($pluginName, $configFiles, $return_errors = FALSE)
{
    global $compatibility_disable_config_check;
    if ($compatibility_disable_config_check) {
        return;
    }
    global $compatibility_sm_path;
    // check one at a time...
    //
    foreach ($configFiles as $configFile) {
        if (strpos($configFile, '/') === 0) {
            $plugin_path = $configFile;
        } else {
            $plugin_path = $compatibility_sm_path . 'plugins/' . $pluginName . '/' . $configFile;
        }
        if (!file_exists($plugin_path)) {
            //if ($return_errors) return FALSE;
            sq_change_text_domain('compatibility');
            if ($return_errors) {
                $error_msg = sprintf(_("The file %s is missing from plugin %s."), '&quot;<strong>' . $configFile . '</strong>&quot;', '&quot;<strong>' . $pluginName . '</strong>&quot;');
                sq_change_text_domain('squirrelmail');
                return $error_msg;
            }
            $error_msg = _("Administrative error:") . '<br />' . sprintf(_("The plugin %s has not been set up correctly."), '&quot;<strong>' . $pluginName . '</strong>&quot;') . '<br />' . sprintf(_("The file %s is missing."), '&quot;<strong>' . $configFile . '</strong>&quot;') . '<br />' . _("Please read the README or INSTALL files that came with the plugin.");
            sq_change_text_domain('squirrelmail');
            include_once $compatibility_sm_path . 'functions/display_messages.php';
            global $color;
            plain_error_message($error_msg, $color);
            exit;
        }
    }
    return TRUE;
}
Ejemplo n.º 12
0
    }
    $oTemplate->display('footer.tpl');
    exit;
} elseif (!empty($addrquery)) {
    /* Do the search */
    if ($backend == -1) {
        $res = $abook->s_search($addrquery);
    } else {
        $res = $abook->s_search($addrquery, $backend);
    }
    if (!is_array($res)) {
        plain_error_message(_("Your search failed with the following error(s)") . ':<br />' . nl2br(sm_encode_html_special_chars($abook->error)));
    } elseif (sizeof($res) == 0) {
        $oTemplate->assign('note', _("No persons matching your search were found"));
        $oTemplate->display('note.tpl');
    } else {
        addr_display_result($res);
    }
} else {
    // not first time display, not listall and search is empty
    // TODO: I think, this part of control structure is never reached.
    plain_error_message(_("Nothing to search"));
}
if ($addrquery == '' || sizeof($res) == 0) {
    //FIXME don't echo HTML from core -- especially convoluted given that there is template code immediately above AND below this block
    echo '<div style="text-align: center;">' . addForm('compose.php', 'post', 'k', '', '', array(), TRUE);
    addr_insert_hidden();
    echo '<input type="submit" value="' . _("Return") . '" name="return" />' . "\n" . '</form></div></nobr>';
}
echo '<hr />';
$oTemplate->display('footer.tpl');
Ejemplo n.º 13
0
/**
 * temporary function to make use of the deliver class.
 * In the future the responsible backend should be automaticly loaded
 * and conf.pl should show a list of available backends.
 * The message also should be constructed by the message class.
 *
 * @param object $composeMessage The message being sent.  Please note
 *                               that it is passed by reference and
 *                               will be returned modified, with additional
 *                               headers, such as Message-ID, Date, In-Reply-To,
 *                               References, and so forth.
 *
 * @return boolean FALSE if delivery failed, or some non-FALSE value
 *                 upon success.
 *
 */
function deliverMessage(&$composeMessage, $draft = false)
{
    global $send_to, $send_to_cc, $send_to_bcc, $mailprio, $subject, $body, $username, $identity, $idents, $data_dir, $request_mdn, $request_dr, $default_charset, $useSendmail, $domain, $action, $default_move_to_sent, $move_to_sent, $imapServerAddress, $imapPort, $imap_stream_options, $sent_folder, $key;
    $rfc822_header = $composeMessage->rfc822_header;
    $abook = addressbook_init(false, true);
    $rfc822_header->to = $rfc822_header->parseAddress($send_to, true, array(), '', $domain, array(&$abook, 'lookup'));
    $rfc822_header->cc = $rfc822_header->parseAddress($send_to_cc, true, array(), '', $domain, array(&$abook, 'lookup'));
    $rfc822_header->bcc = $rfc822_header->parseAddress($send_to_bcc, true, array(), '', $domain, array(&$abook, 'lookup'));
    $rfc822_header->priority = $mailprio;
    $rfc822_header->subject = $subject;
    $special_encoding = '';
    if (strtolower($default_charset) == 'iso-2022-jp') {
        if (mb_detect_encoding($body) == 'ASCII') {
            $special_encoding = '8bit';
        } else {
            $body = mb_convert_encoding($body, 'JIS');
            $special_encoding = '7bit';
        }
    }
    $composeMessage->setBody($body);
    $reply_to = '';
    $reply_to = $idents[$identity]['reply_to'];
    if ($reply_to && strpos($reply_to, '@') === FALSE) {
        $reply_to .= '@' . $domain;
    }
    $from_addr = build_from_header($identity);
    $rfc822_header->from = $rfc822_header->parseAddress($from_addr, true);
    if ($reply_to) {
        $rfc822_header->reply_to = $rfc822_header->parseAddress($reply_to, true);
    }
    /* Receipt: On Read */
    if (isset($request_mdn) && $request_mdn) {
        $rfc822_header->dnt = $rfc822_header->parseAddress($from_addr, true);
    } elseif (isset($rfc822_header->dnt)) {
        unset($rfc822_header->dnt);
    }
    /* Receipt: On Delivery */
    if (!empty($request_dr)) {
        //FIXME: it would be better to fiddle with headers inside of the message object or possibly when delivering the message to its destination; is this possible?
        $rfc822_header->more_headers['Return-Receipt-To'] = $from_addr;
    } elseif (isset($rfc822_header->more_headers['Return-Receipt-To'])) {
        unset($rfc822_header->more_headers['Return-Receipt-To']);
    }
    /* multipart messages */
    if (count($composeMessage->entities)) {
        $message_body = new Message();
        $message_body->body_part = $composeMessage->body_part;
        $composeMessage->body_part = '';
        $mime_header = new MessageHeader();
        $mime_header->type0 = 'text';
        $mime_header->type1 = 'plain';
        if ($special_encoding) {
            $mime_header->encoding = $special_encoding;
        } else {
            $mime_header->encoding = '8bit';
        }
        if ($default_charset) {
            $mime_header->parameters['charset'] = $default_charset;
        }
        $message_body->mime_header = $mime_header;
        array_unshift($composeMessage->entities, $message_body);
        $content_type = new ContentType('multipart/mixed');
    } else {
        $content_type = new ContentType('text/plain');
        if ($special_encoding) {
            $rfc822_header->encoding = $special_encoding;
        } else {
            $rfc822_header->encoding = '8bit';
        }
        if ($default_charset) {
            $content_type->properties['charset'] = $default_charset;
        }
    }
    $rfc822_header->content_type = $content_type;
    $composeMessage->rfc822_header = $rfc822_header;
    if ($action == 'reply' || $action == 'reply_all') {
        global $passed_id, $passed_ent_id;
        $reply_id = $passed_id;
        $reply_ent_id = $passed_ent_id;
    } else {
        $reply_id = '';
        $reply_ent_id = '';
    }
    /* Here you can modify the message structure just before we hand
       it over to deliver; plugin authors note that $composeMessage
       is sent and modified by reference since 1.5.2 */
    do_hook('compose_send', $composeMessage);
    if (!$useSendmail && !$draft) {
        require_once SM_PATH . 'class/deliver/Deliver_SMTP.class.php';
        $deliver = new Deliver_SMTP();
        global $smtpServerAddress, $smtpPort, $smtp_stream_options, $pop_before_smtp, $pop_before_smtp_host;
        $authPop = isset($pop_before_smtp) && $pop_before_smtp ? true : false;
        if (empty($pop_before_smtp_host)) {
            $pop_before_smtp_host = $smtpServerAddress;
        }
        get_smtp_user($user, $pass);
        $stream = $deliver->initStream($composeMessage, $domain, 0, $smtpServerAddress, $smtpPort, $user, $pass, $authPop, $pop_before_smtp_host, $smtp_stream_options);
    } elseif (!$draft) {
        require_once SM_PATH . 'class/deliver/Deliver_SendMail.class.php';
        global $sendmail_path, $sendmail_args;
        // Check for outdated configuration
        if (!isset($sendmail_args)) {
            if ($sendmail_path == '/var/qmail/bin/qmail-inject') {
                $sendmail_args = '';
            } else {
                $sendmail_args = '-i -t';
            }
        }
        $deliver = new Deliver_SendMail(array('sendmail_args' => $sendmail_args));
        $stream = $deliver->initStream($composeMessage, $sendmail_path);
    } elseif ($draft) {
        global $draft_folder;
        $imap_stream = sqimap_login($username, false, $imapServerAddress, $imapPort, 0, $imap_stream_options);
        if (sqimap_mailbox_exists($imap_stream, $draft_folder)) {
            require_once SM_PATH . 'class/deliver/Deliver_IMAP.class.php';
            $imap_deliver = new Deliver_IMAP();
            $success = $imap_deliver->mail($composeMessage, $imap_stream, $reply_id, $reply_ent_id, $imap_stream, $draft_folder);
            sqimap_logout($imap_stream);
            unset($imap_deliver);
            $composeMessage->purgeAttachments();
            return $success;
        } else {
            $msg = '<br />' . sprintf(_("Error: Draft folder %s does not exist."), sm_encode_html_special_chars($draft_folder));
            plain_error_message($msg);
            return false;
        }
    }
    $success = false;
    if ($stream) {
        $deliver->mail($composeMessage, $stream, $reply_id, $reply_ent_id);
        $success = $deliver->finalizeStream($stream);
    }
    if (!$success) {
        // $deliver->dlv_server_msg is not always server's reply
        $msg = _("Message not sent.") . "<br />\n" . (isset($deliver->dlv_msg) ? $deliver->dlv_msg : '');
        if (!empty($deliver->dlv_server_msg)) {
            // add 'server replied' part only when it is not empty.
            // Delivery error can be generated by delivery class itself
            $msg .= '<br />' . _("Server replied:") . ' ' . (isset($deliver->dlv_ret_nr) ? $deliver->dlv_ret_nr . ' ' : '') . nl2br(sm_encode_html_special_chars($deliver->dlv_server_msg));
        }
        plain_error_message($msg);
    } else {
        unset($deliver);
        $imap_stream = sqimap_login($username, false, $imapServerAddress, $imapPort, 0, $imap_stream_options);
        // mark as replied or forwarded if applicable
        //
        global $what, $iAccount, $startMessage, $passed_id, $fwduid, $mailbox;
        if ($action == 'reply' || $action == 'reply_all' || $action == 'forward' || $action == 'forward_as_attachment') {
            require SM_PATH . 'functions/mailbox_display.php';
            $aMailbox = sqm_api_mailbox_select($imap_stream, $iAccount, $mailbox, array('setindex' => $what, 'offset' => $startMessage), array());
            switch ($action) {
                case 'reply':
                case 'reply_all':
                    // check if we are allowed to set the \\Answered flag
                    if (in_array('\\answered', $aMailbox['PERMANENTFLAGS'], true)) {
                        $aUpdatedMsgs = sqimap_toggle_flag($imap_stream, array($passed_id), '\\Answered', true, false);
                        if (isset($aUpdatedMsgs[$passed_id]['FLAGS'])) {
                            /**
                             * Only update the cached headers if the header is
                             * cached.
                             */
                            if (isset($aMailbox['MSG_HEADERS'][$passed_id])) {
                                $aMailbox['MSG_HEADERS'][$passed_id]['FLAGS'] = $aMsg['FLAGS'];
                            }
                        }
                    }
                    break;
                case 'forward':
                case 'forward_as_attachment':
                    // check if we are allowed to set the $Forwarded flag (RFC 4550 paragraph 2.8)
                    if (in_array('$forwarded', $aMailbox['PERMANENTFLAGS'], true) || in_array('\\*', $aMailbox['PERMANENTFLAGS'])) {
                        // when forwarding as an attachment from the message
                        // list, passed_id is not used, need to get UID(s)
                        // from the query string
                        //
                        if (empty($passed_id) && !empty($fwduid)) {
                            $ids = explode('_', $fwduid);
                        } else {
                            $ids = array($passed_id);
                        }
                        $aUpdatedMsgs = sqimap_toggle_flag($imap_stream, $ids, '$Forwarded', true, false);
                        foreach ($ids as $id) {
                            if (isset($aUpdatedMsgs[$id]['FLAGS'])) {
                                if (isset($aMailbox['MSG_HEADERS'][$id])) {
                                    $aMailbox['MSG_HEADERS'][$id]['FLAGS'] = $aMsg['FLAGS'];
                                }
                            }
                        }
                    }
                    break;
            }
            /**
             * Write mailbox with updated seen flag information back to cache.
             */
            if (isset($aUpdatedMsgs[$passed_id])) {
                $mailbox_cache[$iAccount . '_' . $aMailbox['NAME']] = $aMailbox;
                sqsession_register($mailbox_cache, 'mailbox_cache');
            }
        }
        // move to sent folder
        //
        $move_to_sent = getPref($data_dir, $username, 'move_to_sent');
        if (isset($default_move_to_sent) && $default_move_to_sent != 0) {
            $svr_allow_sent = true;
        } else {
            $svr_allow_sent = false;
        }
        if (isset($sent_folder) && ($sent_folder != '' || $sent_folder != 'none') && sqimap_mailbox_exists($imap_stream, $sent_folder)) {
            $fld_sent = true;
        } else {
            $fld_sent = false;
        }
        if (isset($move_to_sent) && $move_to_sent != 0 || !isset($move_to_sent)) {
            $lcl_allow_sent = true;
        } else {
            $lcl_allow_sent = false;
        }
        if ($fld_sent && $svr_allow_sent && !$lcl_allow_sent || $fld_sent && $lcl_allow_sent) {
            if ($action == 'reply' || $action == 'reply_all') {
                $save_reply_with_orig = getPref($data_dir, $username, 'save_reply_with_orig');
                if ($save_reply_with_orig) {
                    $sent_folder = $mailbox;
                }
            }
            require_once SM_PATH . 'class/deliver/Deliver_IMAP.class.php';
            $imap_deliver = new Deliver_IMAP();
            $imap_deliver->mail($composeMessage, $imap_stream, $reply_id, $reply_ent_id, $imap_stream, $sent_folder);
            unset($imap_deliver);
        }
        // final cleanup
        //
        $composeMessage->purgeAttachments();
        sqimap_logout($imap_stream);
    }
    return $success;
}
Ejemplo n.º 14
0
/**
 * This function builds an array with all the information about
 * the options available to the user, and returns it. The options
 * are grouped by the groups in which they are displayed.
 * For each option, the following information is stored:
 * - name: the internal (variable) name
 * - caption: the description of the option in the UI
 * - type: one of SMOPT_TYPE_*
 * - refresh: one of SMOPT_REFRESH_*
 * - size: one of SMOPT_SIZE_*
 * - save: the name of a function to call when saving this option
 * @return array all option information
 */
function load_optpage_data_personal()
{
    global $data_dir, $username, $edit_identity, $edit_name, $edit_reply_to, $full_name, $reply_to, $email_address, $signature, $tzChangeAllowed, $timeZone, $domain;
    /* Set the values of some global variables. */
    $full_name = getPref($data_dir, $username, 'full_name');
    $reply_to = getPref($data_dir, $username, 'reply_to');
    $email_address = getPref($data_dir, $username, 'email_address', SMPREF_NONE);
    $signature = getSig($data_dir, $username, 'g');
    // set email_address to default value, if it is not set in user's preferences
    if ($email_address == SMPREF_NONE) {
        if (preg_match("/(.+)@(.+)/", $username)) {
            $email_address = $username;
        } else {
            $email_address = $username . '@' . $domain;
        }
    }
    /* Build a simple array into which we will build options. */
    $optgrps = array();
    $optvals = array();
    /******************************************************/
    /* LOAD EACH GROUP OF OPTIONS INTO THE OPTIONS ARRAY. */
    /******************************************************/
    /*** Load the Contact Information Options into the array ***/
    $optgrps[SMOPT_GRP_CONTACT] = _("Name and Address Options");
    $optvals[SMOPT_GRP_CONTACT] = array();
    /* Build a simple array into which we will build options. */
    $optvals = array();
    if (!isset($edit_identity)) {
        $edit_identity = TRUE;
    }
    if ($edit_identity || $edit_name) {
        $optvals[SMOPT_GRP_CONTACT][] = array('name' => 'full_name', 'caption' => _("Full Name"), 'type' => SMOPT_TYPE_STRING, 'refresh' => SMOPT_REFRESH_NONE, 'size' => SMOPT_SIZE_HUGE);
    } else {
        $optvals[SMOPT_GRP_CONTACT][] = array('name' => 'full_name', 'caption' => _("Full Name"), 'type' => SMOPT_TYPE_COMMENT, 'refresh' => SMOPT_REFRESH_NONE, 'comment' => $full_name);
    }
    if ($edit_identity) {
        $optvals[SMOPT_GRP_CONTACT][] = array('name' => 'email_address', 'caption' => _("E-mail Address"), 'type' => SMOPT_TYPE_STRING, 'refresh' => SMOPT_REFRESH_NONE, 'size' => SMOPT_SIZE_HUGE);
    } else {
        $optvals[SMOPT_GRP_CONTACT][] = array('name' => 'email_address', 'caption' => _("E-mail Address"), 'type' => SMOPT_TYPE_COMMENT, 'refresh' => SMOPT_REFRESH_NONE, 'comment' => sm_encode_html_special_chars($email_address));
    }
    if ($edit_identity || $edit_reply_to) {
        $optvals[SMOPT_GRP_CONTACT][] = array('name' => 'reply_to', 'caption' => _("Reply To"), 'type' => SMOPT_TYPE_STRING, 'refresh' => SMOPT_REFRESH_NONE, 'size' => SMOPT_SIZE_HUGE);
    } else {
        //TODO: For many users, this is redundant to the email address above, especially if not editable -- so here instead of a comment, we could just hide it... in fact, that's what we'll do, but keep this code for posterity in case someone decides we shouldn't do this
        /*
                $optvals[SMOPT_GRP_CONTACT][] = array(
                    'name'    => 'reply_to',
                    'caption' => _("Reply To"),
                    'type'    => SMOPT_TYPE_COMMENT,
                    'refresh' => SMOPT_REFRESH_NONE,
                    'comment' => sm_encode_html_special_chars($reply_to),
                );
        */
    }
    $optvals[SMOPT_GRP_CONTACT][] = array('name' => 'signature', 'caption' => _("Signature"), 'type' => SMOPT_TYPE_TEXTAREA, 'refresh' => SMOPT_REFRESH_NONE, 'size' => SMOPT_SIZE_MEDIUM, 'save' => 'save_option_signature');
    if ($edit_identity) {
        $identities_link_value = '<a href="options_identities.php">' . _("Edit Advanced Identities") . '</a> ' . _("(discards changes made on this form so far)");
        $optvals[SMOPT_GRP_CONTACT][] = array('name' => 'identities_link', 'caption' => _("Multiple Identities"), 'type' => SMOPT_TYPE_COMMENT, 'refresh' => SMOPT_REFRESH_NONE, 'comment' => $identities_link_value);
    }
    if ($tzChangeAllowed || function_exists('date_default_timezone_set')) {
        $TZ_ARRAY[SMPREF_NONE] = _("Same as server");
        $aTimeZones = sq_get_tz_array();
        unset($message);
        if (!empty($aTimeZones)) {
            // check if current timezone is linked to other TZ and update it
            if ($timeZone != SMPREF_NONE && $timeZone != "" && isset($aTimeZones[$timeZone]['LINK'])) {
                $timeZone = $aTimeZones[$timeZone]['LINK'];
                // TODO: recheck setting of $timeZone
                // setPref($data_dir,$username,'timezone',$timeZone);
            }
            // sort time zones by name. sq_get_tz_array() returns sorted by key.
            // asort($aTimeZones);
            // add all 'TZ' entries to TZ_ARRAY
            foreach ($aTimeZones as $TzKey => $TzData) {
                if (!isset($TzData['LINK'])) {
                    // Old display format
                    $TZ_ARRAY[$TzKey] = $TzKey;
                    // US Eastern standard time (America/New_York) - needs asort($aTimeZones)
                    //$TZ_ARRAY[$TzKey] = (isset($TzData['NAME']) ? $TzData['NAME']." ($TzKey)" : "($TzKey)");
                    // US Eastern standard time if NAME is present or America/New_York if NAME not present
                    // needs sorting after all data is added or uasort()
                    //$TZ_ARRAY[$TzKey] = (isset($TzData['NAME']) ? $TzData['NAME'] : $TzKey);
                    // (America/New_Your) US Eastern standard time
                    //$TZ_ARRAY[$TzKey] = "($TzKey)" . (isset($TzData['NAME']) ? ' '.$TzData['NAME'] : '');
                }
            }
        } else {
            $message = _("Error opening timezone config, contact administrator.");
        }
        // TODO: make error user friendly
        if (isset($message)) {
            plain_error_message($message);
            exit;
        }
        $optgrps[SMOPT_GRP_TZ] = _("Timezone Options");
        $optvals[SMOPT_GRP_TZ] = array();
        $optvals[SMOPT_GRP_TZ][] = array('name' => 'timezone', 'caption' => _("Your current timezone"), 'type' => SMOPT_TYPE_STRLIST, 'refresh' => SMOPT_REFRESH_NONE, 'posvals' => $TZ_ARRAY);
    }
    /*** Load the Reply Citation Options into the array ***/
    $optgrps[SMOPT_GRP_REPLY] = _("Reply Citation Options");
    $optvals[SMOPT_GRP_REPLY] = array();
    $optvals[SMOPT_GRP_REPLY][] = array('name' => 'reply_citation_style', 'caption' => _("Reply Citation Style"), 'type' => SMOPT_TYPE_STRLIST, 'refresh' => SMOPT_REFRESH_NONE, 'posvals' => array(SMPREF_NONE => _("No Citation"), 'author_said' => _("AUTHOR Wrote"), 'date_time_author' => _("On DATE, AUTHOR Wrote"), 'quote_who' => _("Quote Who XML"), 'user-defined' => _("User-Defined")));
    $optvals[SMOPT_GRP_REPLY][] = array('name' => 'reply_citation_start', 'caption' => _("User-Defined Citation Start"), 'type' => SMOPT_TYPE_STRING, 'refresh' => SMOPT_REFRESH_NONE, 'size' => SMOPT_SIZE_MEDIUM);
    $optvals[SMOPT_GRP_REPLY][] = array('name' => 'reply_citation_end', 'caption' => _("User-Defined Citation End"), 'type' => SMOPT_TYPE_STRING, 'refresh' => SMOPT_REFRESH_NONE, 'size' => SMOPT_SIZE_MEDIUM);
    /*** Load the Signature Options into the array ***/
    $optgrps[SMOPT_GRP_SIG] = _("Signature Options");
    $optvals[SMOPT_GRP_SIG] = array();
    $optvals[SMOPT_GRP_SIG][] = array('name' => 'use_signature', 'caption' => _("Use Signature"), 'type' => SMOPT_TYPE_BOOLEAN, 'refresh' => SMOPT_REFRESH_NONE);
    $optvals[SMOPT_GRP_SIG][] = array('name' => 'prefix_sig', 'caption' => _("Prefix Signature with '-- ' Line"), 'type' => SMOPT_TYPE_BOOLEAN, 'refresh' => SMOPT_REFRESH_NONE);
    /* Assemble all this together and return it as our result. */
    $result = array('grps' => $optgrps, 'vals' => $optvals);
    return $result;
}
Ejemplo n.º 15
0
function deliverMessage($composeMessage, $draft = false)
{
    global $send_to, $send_to_cc, $send_to_bcc, $mailprio, $subject, $body, $username, $popuser, $usernamedata, $identity, $idents, $data_dir, $request_mdn, $request_dr, $default_charset, $color, $useSendmail, $domain, $action, $default_move_to_sent, $move_to_sent;
    global $imapServerAddress, $imapPort, $sent_folder, $key;
    $rfc822_header = $composeMessage->rfc822_header;
    $abook = addressbook_init(false, true);
    $rfc822_header->to = $rfc822_header->parseAddress($send_to, true, array(), '', $domain, array(&$abook, 'lookup'));
    $rfc822_header->cc = $rfc822_header->parseAddress($send_to_cc, true, array(), '', $domain, array(&$abook, 'lookup'));
    $rfc822_header->bcc = $rfc822_header->parseAddress($send_to_bcc, true, array(), '', $domain, array(&$abook, 'lookup'));
    $rfc822_header->priority = $mailprio;
    $rfc822_header->subject = $subject;
    $special_encoding = '';
    if (strtolower($default_charset) == 'iso-2022-jp') {
        if (mb_detect_encoding($body) == 'ASCII') {
            $special_encoding = '8bit';
        } else {
            $body = mb_convert_encoding($body, 'JIS');
            $special_encoding = '7bit';
        }
    }
    $composeMessage->setBody($body);
    if (ereg("^([^@%/]+)[@%/](.+)\$", $username, $usernamedata)) {
        $popuser = $usernamedata[1];
        $domain = $usernamedata[2];
        unset($usernamedata);
    } else {
        $popuser = $username;
    }
    $reply_to = '';
    $from_mail = $idents[$identity]['email_address'];
    $full_name = $idents[$identity]['full_name'];
    $reply_to = $idents[$identity]['reply_to'];
    if (!$from_mail) {
        $from_mail = "{$popuser}@{$domain}";
    }
    $rfc822_header->from = $rfc822_header->parseAddress($from_mail, true);
    if ($full_name) {
        $from = $rfc822_header->from[0];
        if (!$from->host) {
            $from->host = $domain;
        }
        $full_name_encoded = encodeHeader($full_name);
        if ($full_name_encoded != $full_name) {
            $from_addr = $full_name_encoded . ' <' . $from->mailbox . '@' . $from->host . '>';
        } else {
            $from_addr = '"' . $full_name . '" <' . $from->mailbox . '@' . $from->host . '>';
        }
        $rfc822_header->from = $rfc822_header->parseAddress($from_addr, true);
    }
    if ($reply_to) {
        $rfc822_header->reply_to = $rfc822_header->parseAddress($reply_to, true);
    }
    /* Receipt: On Read */
    if (isset($request_mdn) && $request_mdn) {
        $rfc822_header->dnt = $rfc822_header->parseAddress($from_mail, true);
    }
    /* Receipt: On Delivery */
    if (isset($request_dr) && $request_dr) {
        $rfc822_header->more_headers['Return-Receipt-To'] = $from_mail;
    }
    /* multipart messages */
    if (count($composeMessage->entities)) {
        $message_body = new Message();
        $message_body->body_part = $composeMessage->body_part;
        $composeMessage->body_part = '';
        $mime_header = new MessageHeader();
        $mime_header->type0 = 'text';
        $mime_header->type1 = 'plain';
        if ($special_encoding) {
            $mime_header->encoding = $special_encoding;
        } else {
            $mime_header->encoding = '8bit';
        }
        if ($default_charset) {
            $mime_header->parameters['charset'] = $default_charset;
        }
        $message_body->mime_header = $mime_header;
        array_unshift($composeMessage->entities, $message_body);
        $content_type = new ContentType('multipart/mixed');
    } else {
        $content_type = new ContentType('text/plain');
        if ($special_encoding) {
            $rfc822_header->encoding = $special_encoding;
        } else {
            $rfc822_header->encoding = '8bit';
        }
        if ($default_charset) {
            $content_type->properties['charset'] = $default_charset;
        }
    }
    $rfc822_header->content_type = $content_type;
    $composeMessage->rfc822_header = $rfc822_header;
    /* Here you can modify the message structure just before we hand
       it over to deliver */
    $hookReturn = do_hook('compose_send', $composeMessage);
    /* Get any changes made by plugins to $composeMessage. */
    if (is_object($hookReturn[1])) {
        $composeMessage = $hookReturn[1];
    }
    if (!$useSendmail && !$draft) {
        require_once SM_PATH . 'class/deliver/Deliver_SMTP.class.php';
        $deliver = new Deliver_SMTP();
        global $smtpServerAddress, $smtpPort, $pop_before_smtp, $smtp_auth_mech;
        $authPop = isset($pop_before_smtp) && $pop_before_smtp ? true : false;
        get_smtp_user($user, $pass);
        $stream = $deliver->initStream($composeMessage, $domain, 0, $smtpServerAddress, $smtpPort, $user, $pass, $authPop);
    } elseif (!$draft) {
        require_once SM_PATH . 'class/deliver/Deliver_SendMail.class.php';
        global $sendmail_path;
        $deliver = new Deliver_SendMail();
        $stream = $deliver->initStream($composeMessage, $sendmail_path);
    } elseif ($draft) {
        global $draft_folder;
        require_once SM_PATH . 'class/deliver/Deliver_IMAP.class.php';
        $imap_stream = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
        if (sqimap_mailbox_exists($imap_stream, $draft_folder)) {
            require_once SM_PATH . 'class/deliver/Deliver_IMAP.class.php';
            $imap_deliver = new Deliver_IMAP();
            $length = $imap_deliver->mail($composeMessage);
            sqimap_append($imap_stream, $draft_folder, $length);
            $imap_deliver->mail($composeMessage, $imap_stream);
            sqimap_append_done($imap_stream, $draft_folder);
            sqimap_logout($imap_stream);
            unset($imap_deliver);
            return $length;
        } else {
            $msg = '<br />' . sprintf(_("Error: Draft folder %s does not exist."), $draft_folder);
            plain_error_message($msg, $color);
            return false;
        }
    }
    $succes = false;
    if ($stream) {
        $length = $deliver->mail($composeMessage, $stream);
        $succes = $deliver->finalizeStream($stream);
    }
    if (!$succes) {
        $msg = $deliver->dlv_msg . '<br />' . _("Server replied: ") . $deliver->dlv_ret_nr . ' ' . $deliver->dlv_server_msg;
        plain_error_message($msg, $color);
    } else {
        unset($deliver);
        $move_to_sent = getPref($data_dir, $username, 'move_to_sent');
        $imap_stream = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
        /* Move to sent code */
        if (isset($default_move_to_sent) && $default_move_to_sent != 0) {
            $svr_allow_sent = true;
        } else {
            $svr_allow_sent = false;
        }
        if (isset($sent_folder) && ($sent_folder != '' || $sent_folder != 'none') && sqimap_mailbox_exists($imap_stream, $sent_folder)) {
            $fld_sent = true;
        } else {
            $fld_sent = false;
        }
        if (isset($move_to_sent) && $move_to_sent != 0 || !isset($move_to_sent)) {
            $lcl_allow_sent = true;
        } else {
            $lcl_allow_sent = false;
        }
        if ($fld_sent && $svr_allow_sent && !$lcl_allow_sent || $fld_sent && $lcl_allow_sent) {
            global $passed_id, $mailbox, $action;
            if ($action == 'reply' || $action == 'reply_all') {
                $save_reply_with_orig = getPref($data_dir, $username, 'save_reply_with_orig');
                if ($save_reply_with_orig) {
                    $sent_folder = $mailbox;
                }
            }
            sqimap_append($imap_stream, $sent_folder, $length);
            require_once SM_PATH . 'class/deliver/Deliver_IMAP.class.php';
            $imap_deliver = new Deliver_IMAP();
            $imap_deliver->mail($composeMessage, $imap_stream);
            sqimap_append_done($imap_stream, $sent_folder);
            unset($imap_deliver);
        }
        global $passed_id, $mailbox, $action;
        ClearAttachments($composeMessage);
        if ($action == 'reply' || $action == 'reply_all') {
            sqimap_mailbox_select($imap_stream, $mailbox);
            sqimap_messages_flag($imap_stream, $passed_id, $passed_id, 'Answered', false);
        }
        sqimap_logout($imap_stream);
    }
    return $succes;
}
Ejemplo n.º 16
0
require_once SM_PATH . 'functions/html.php';
require_once SM_PATH . 'functions/forms.php';
/*
 *  Incoming values:
 *     $mailbox - selected mailbox from the form
 */
/* globals */
sqgetGlobalVar('key', $key, SQ_COOKIE);
sqgetGlobalVar('username', $username, SQ_SESSION);
sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION);
sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION);
sqgetGlobalVar('mailbox', $mailbox, SQ_POST);
/* end globals */
if ($mailbox == '') {
    displayPageHeader($color, 'None');
    plain_error_message(_("You have not selected a folder to delete. Please do so.") . '<br /><a href="../src/folders.php">' . _("Click here to go back") . '</a>.', $color);
    exit;
}
if (sqgetGlobalVar('backingout', $tmp, SQ_POST)) {
    $location = get_location();
    header("Location: {$location}/folders.php");
    exit;
}
if (!sqgetGlobalVar('confirmed', $tmp, SQ_POST)) {
    displayPageHeader($color, 'None');
    echo '<br />' . html_tag('table', '', 'center', '', 'width="95%" border="0"') . html_tag('tr', html_tag('td', '<b>' . _("Delete Folder") . '</b>', 'center', $color[0])) . html_tag('tr') . html_tag('td', '', 'center', $color[4]) . sprintf(_("Are you sure you want to delete %s?"), str_replace(array(' ', '<', '>'), array('&nbsp;', '&lt;', '&gt;'), imap_utf7_decode_local($mailbox))) . addForm('folders_delete.php', 'post') . "<p>\n" . addHidden('mailbox', $mailbox) . addSubmit(_("Yes"), 'confirmed') . addSubmit(_("No"), 'backingout') . '</p></form><br /></td></tr></table>';
    exit;
}
$imap_stream = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
$boxes = sqimap_mailbox_list($imap_stream);
$numboxes = count($boxes);
Ejemplo n.º 17
0
function SendMDN($mailbox, $passed_id, $sender, $message, $imapConnection)
{
    global $username, $attachment_dir, $version, $attachments, $squirrelmail_language, $default_charset, $languages, $useSendmail, $domain, $sent_folder, $popuser, $data_dir, $username;
    sqgetGlobalVar('SERVER_NAME', $SERVER_NAME, SQ_SERVER);
    $header = $message->rfc822_header;
    $hashed_attachment_dir = getHashedDir($username, $attachment_dir);
    $rfc822_header = new Rfc822Header();
    $content_type = new ContentType('multipart/report');
    $content_type->properties['report-type'] = 'disposition-notification';
    set_my_charset();
    if ($default_charset) {
        $content_type->properties['charset'] = $default_charset;
    }
    $rfc822_header->content_type = $content_type;
    $rfc822_header->to[] = $header->dnt;
    $rfc822_header->subject = _("Read:") . ' ' . encodeHeader($header->subject);
    // Patch #793504 Return Receipt Failing with <@> from Tim Craig (burny_md)
    // This merely comes from compose.php and only happens when there is no
    // email_addr specified in user's identity (which is the startup config)
    if (ereg("^([^@%/]+)[@%/](.+)\$", $username, $usernamedata)) {
        $popuser = $usernamedata[1];
        $domain = $usernamedata[2];
        unset($usernamedata);
    } else {
        $popuser = $username;
    }
    $reply_to = '';
    $ident = get_identities();
    if (!isset($identity)) {
        $identity = 0;
    }
    $full_name = $ident[$identity]['full_name'];
    $from_mail = $ident[$identity]['email_address'];
    $from_addr = '"' . $full_name . '" <' . $from_mail . '>';
    $reply_to = $ident[$identity]['reply_to'];
    if (!$from_mail) {
        $from_mail = "{$popuser}@{$domain}";
        $from_addr = $from_mail;
    }
    $rfc822_header->from = $rfc822_header->parseAddress($from_addr, true);
    if ($reply_to) {
        $rfc822_header->reply_to = $rfc822_header->parseAddress($reply_to, true);
    }
    // part 1 (RFC2298)
    $senton = getLongDateString($header->date);
    $to_array = $header->to;
    $to = '';
    foreach ($to_array as $line) {
        $to .= ' ' . $line->getAddress();
    }
    $now = getLongDateString(time());
    set_my_charset();
    $body = _("Your message") . "\r\n\r\n" . "\t" . _("To") . ': ' . decodeHeader($to, false, false) . "\r\n" . "\t" . _("Subject") . ': ' . decodeHeader($header->subject, false, false) . "\r\n" . "\t" . _("Sent") . ': ' . $senton . "\r\n" . "\r\n" . sprintf(_("Was displayed on %s"), $now);
    $special_encoding = '';
    if (isset($languages[$squirrelmail_language]['XTRA_CODE']) && function_exists($languages[$squirrelmail_language]['XTRA_CODE'] . '_encode')) {
        $body = call_user_func($languages[$squirrelmail_language]['XTRA_CODE'] . '_encode', $body);
        if (strtolower($default_charset) == 'iso-2022-jp') {
            if (mb_detect_encoding($body) == 'ASCII') {
                $special_encoding = '8bit';
            } else {
                $body = mb_convert_encoding($body, 'JIS');
                $special_encoding = '7bit';
            }
        }
    } elseif (sq_is8bit($body)) {
        $special_encoding = '8bit';
    }
    $part1 = new Message();
    $part1->setBody($body);
    $mime_header = new MessageHeader();
    $mime_header->type0 = 'text';
    $mime_header->type1 = 'plain';
    if ($special_encoding) {
        $mime_header->encoding = $special_encoding;
    } else {
        $mime_header->encoding = 'us-ascii';
    }
    if ($default_charset) {
        $mime_header->parameters['charset'] = $default_charset;
    }
    $part1->mime_header = $mime_header;
    // part2  (RFC2298)
    $original_recipient = $to;
    $original_message_id = $header->message_id;
    $report = "Reporting-UA : {$SERVER_NAME} ; SquirrelMail (version {$version}) \r\n";
    if ($original_recipient != '') {
        $report .= "Original-Recipient : {$original_recipient}\r\n";
    }
    $final_recipient = $sender;
    $report .= "Final-Recipient: rfc822; {$final_recipient}\r\n" . "Original-Message-ID : {$original_message_id}\r\n" . "Disposition: manual-action/MDN-sent-manually; displayed\r\n";
    $part2 = new Message();
    $part2->setBody($report);
    $mime_header = new MessageHeader();
    $mime_header->type0 = 'message';
    $mime_header->type1 = 'disposition-notification';
    $mime_header->encoding = 'us-ascii';
    $part2->mime_header = $mime_header;
    $composeMessage = new Message();
    $composeMessage->rfc822_header = $rfc822_header;
    $composeMessage->addEntity($part1);
    $composeMessage->addEntity($part2);
    if ($useSendmail) {
        require_once SM_PATH . 'class/deliver/Deliver_SendMail.class.php';
        global $sendmail_path;
        $deliver = new Deliver_SendMail();
        $stream = $deliver->initStream($composeMessage, $sendmail_path);
    } else {
        require_once SM_PATH . 'class/deliver/Deliver_SMTP.class.php';
        $deliver = new Deliver_SMTP();
        global $smtpServerAddress, $smtpPort, $smtp_auth_mech, $pop_before_smtp;
        $authPop = isset($pop_before_smtp) && $pop_before_smtp ? true : false;
        get_smtp_user($user, $pass);
        $stream = $deliver->initStream($composeMessage, $domain, 0, $smtpServerAddress, $smtpPort, $user, $pass, $authPop);
    }
    $success = false;
    if ($stream) {
        $length = $deliver->mail($composeMessage, $stream);
        $success = $deliver->finalizeStream($stream);
    }
    if (!$success) {
        $msg = $deliver->dlv_msg . '<br />' . _("Server replied: ") . $deliver->dlv_ret_nr . ' ' . $deliver->dlv_server_msg;
        require_once SM_PATH . 'functions/display_messages.php';
        plain_error_message($msg, $color);
    } else {
        unset($deliver);
        if (sqimap_mailbox_exists($imapConnection, $sent_folder)) {
            sqimap_append($imapConnection, $sent_folder, $length);
            require_once SM_PATH . 'class/deliver/Deliver_IMAP.class.php';
            $imap_deliver = new Deliver_IMAP();
            $imap_deliver->mail($composeMessage, $imapConnection);
            sqimap_append_done($imapConnection);
            unset($imap_deliver);
        }
    }
    return $success;
}