| | |
| | | $http_header .= ' ('. rcmail_encrypt_header($host) . ')'; |
| | | } else { |
| | | $http_header .= (($host != $hostname) ? $hostname : '[' . $host . ']'); |
| | | $http_header .= ' ('. ($host == $hostname ? '' : $hostname . ' ') . |
| | | '[' . $host .'])'; |
| | | if ($host != $hostname) |
| | | $http_header .= ' (['. $host .'])'; |
| | | } |
| | | $http_header .= $nldlm . ' via '; |
| | | } |
| | |
| | | $http_header .= ' ('. rcmail_encrypt_header($host) . ')'; |
| | | } else { |
| | | $http_header .= (($host != $hostname) ? $hostname : '[' . $host . ']'); |
| | | $http_header .= ' ('. ($host == $hostname ? '' : $hostname . ' ') . |
| | | '[' . $host .'])'; |
| | | if ($host != $hostname) |
| | | $http_header .= ' (['. $host .'])'; |
| | | } |
| | | // BY |
| | | $http_header .= $nldlm . 'by ' . $_SERVER['HTTP_HOST']; |
| | | // WITH |
| | | $http_header .= $nldlm . 'with ' . $_SERVER['SERVER_PROTOCOL'] . |
| | | ' ('.$_SERVER['REQUEST_METHOD'] . '); ' . date('r'); |
| | | $http_header .= $nldlm . 'with HTTP (' . $_SERVER['SERVER_PROTOCOL'] . |
| | | ' '.$_SERVER['REQUEST_METHOD'] . '); ' . date('r'); |
| | | $http_header = wordwrap($http_header, 69, $nldlm); |
| | | |
| | | $headers['Received'] = $http_header; |
| | |
| | | |
| | | if (!empty($_SESSION['compose']['reply_msgid'])) |
| | | $headers['In-Reply-To'] = $_SESSION['compose']['reply_msgid']; |
| | | |
| | | // remember reply/forward UIDs in special headers |
| | | if (!empty($_SESSION['compose']['reply_uid']) && $savedraft) |
| | | $headers['X-Draft-Info'] = array('type' => 'reply', 'uid' => $_SESSION['compose']['reply_uid']); |
| | | else if (!empty($_SESSION['compose']['forward_uid']) && $savedraft) |
| | | $headers['X-Draft-Info'] = array('type' => 'forward', 'uid' => $_SESSION['compose']['forward_uid']); |
| | | |
| | | if (!empty($_SESSION['compose']['references'])) |
| | | $headers['References'] = $_SESSION['compose']['references']; |
| | |
| | | $headers['Message-ID'] = $message_id; |
| | | $headers['X-Sender'] = $from; |
| | | |
| | | if (is_array($headers['X-Draft-Info'])) |
| | | $headers['X-Draft-Info'] = rcmail_draftinfo_encode($headers['X-Draft-Info'] + array('folder' => $_SESSION['compose']['mailbox'])); |
| | | |
| | | if (!empty($CONFIG['useragent'])) |
| | | $headers['User-Agent'] = $CONFIG['useragent']; |
| | | |
| | | // exec hook for header checking and manipulation |
| | | $data = $RCMAIL->plugins->exec_hook('outgoing_message_headers', array('headers' => $headers)); |
| | | |
| | | // sending aborted by plugin |
| | | if ($data['abort'] && !$savedraft) { |
| | | $OUTPUT->show_message($data['message'] ? $data['message'] : 'sendingfailed'); |
| | | $OUTPUT->send('iframe'); |
| | | } |
| | | else |
| | | $headers = $data['headers']; |
| | | |
| | | |
| | | $isHtmlVal = strtolower(get_input_value('_is_html', RCUBE_INPUT_POST)); |
| | | $isHtml = ($isHtmlVal == "1"); |
| | |
| | | $message_body = get_input_value('_message', RCUBE_INPUT_POST, TRUE, $message_charset); |
| | | |
| | | if (!$savedraft) { |
| | | // remove signature's div ID |
| | | if ($isHtml) |
| | | if ($isHtml) { |
| | | // remove signature's div ID |
| | | $message_body = preg_replace('/\s*id="_rc_sig"/', '', $message_body); |
| | | |
| | | // add inline css for blockquotes |
| | | $bstyle = 'padding-left:5px; border-left:#1010ff 2px solid; margin-left:5px; width:100%'; |
| | | $message_body = preg_replace('/<blockquote>/', |
| | | '<blockquote type="cite" style="'.$bstyle.'">', $message_body); |
| | | } |
| | | // generic footer for all messages |
| | | if (!empty($CONFIG['generic_message_footer'])) { |
| | | $footer = file_get_contents(realpath($CONFIG['generic_message_footer'])); |
| | |
| | | $MAIL_MIME->setTXTBody($plugin['body'], false, true); |
| | | } |
| | | |
| | | // chose transfer encoding |
| | | $charset_7bit = array('ASCII', 'ISO-2022-JP', 'ISO-8859-1', 'ISO-8859-2', 'ISO-8859-15'); |
| | | $transfer_encoding = in_array(strtoupper($message_charset), $charset_7bit) ? '7bit' : '8bit'; |
| | | |
| | | // add stored attachments, if any |
| | | if (is_array($_SESSION['compose']['attachments'])) |
| | | { |
| | |
| | | $ctype, |
| | | $attachment['name'], |
| | | ($attachment['data'] ? false : true), |
| | | ($ctype == 'message/rfc822' ? $transfer_encoding : 'base64'), |
| | | // @TODO: quoted-printable for message/rfc822 is safe, |
| | | // but we should check that 7bit or 8bit is possible here |
| | | ($ctype == 'message/rfc822' ? 'quoted-printable' : 'base64'), |
| | | ($ctype == 'message/rfc822' ? 'inline' : 'attachment'), |
| | | $message_charset, '', '', |
| | | $CONFIG['mime_param_folding'] ? 'quoted-printable' : NULL, |
| | |
| | | } |
| | | } |
| | | |
| | | // choose transfer encoding for plain/text body |
| | | if (preg_match('/[^\x00-\x7F]/', $MAIL_MIME->getTXTBody())) |
| | | $transfer_encoding = $RCMAIL->config->get('force_7bit') ? 'quoted-printable' : '8bit'; |
| | | else |
| | | $transfer_encoding = '7bit'; |
| | | |
| | | // encoding settings for mail composing |
| | | $MAIL_MIME->setParam('text_encoding', $transfer_encoding); |
| | | $MAIL_MIME->setParam('html_encoding', 'quoted-printable'); |
| | |
| | | $MAIL_MIME->setParam('head_charset', $message_charset); |
| | | $MAIL_MIME->setParam('html_charset', $message_charset); |
| | | $MAIL_MIME->setParam('text_charset', $message_charset); |
| | | |
| | | $data = $RCMAIL->plugins->exec_hook('outgoing_message_headers', array('headers' => $headers)); |
| | | $headers = $data['headers']; |
| | | |
| | | // encoding subject header with mb_encode provides better results with asian characters |
| | | if (function_exists('mb_encode_mimeheader')) |
| | |
| | | if ($olddraftmessageid) |
| | | { |
| | | // delete previous saved draft |
| | | $a_deleteid = $IMAP->search($CONFIG['drafts_mbox'], 'HEADER Message-ID '.$olddraftmessageid); |
| | | |
| | | $deleted = $IMAP->delete_message($IMAP->get_uid($a_deleteid[0], $CONFIG['drafts_mbox']), $CONFIG['drafts_mbox']); |
| | | $a_deleteid = $IMAP->search_once($CONFIG['drafts_mbox'], |
| | | 'HEADER Message-ID '.$olddraftmessageid, true); |
| | | $deleted = $IMAP->delete_message($a_deleteid, $CONFIG['drafts_mbox']); |
| | | |
| | | // raise error if deletion of old draft failed |
| | | if (!$deleted) |
| | |
| | | $msgid = strtr($message_id, array('>' => '', '<' => '')); |
| | | |
| | | // remember new draft-uid |
| | | $draftids = $IMAP->search($CONFIG['drafts_mbox'], 'HEADER Message-ID '.$msgid); |
| | | $_SESSION['compose']['param']['_draft_uid'] = $IMAP->get_uid($draftids[0], $CONFIG['drafts_mbox']); |
| | | $draftuids = $IMAP->search_once($CONFIG['drafts_mbox'], 'HEADER Message-ID '.$msgid, true); |
| | | $_SESSION['compose']['param']['_draft_uid'] = $draftuids[0]; |
| | | |
| | | // display success |
| | | $OUTPUT->show_message('messagesaved', 'confirmation'); |