- function sendMessage($t, $c, $b, $subject, $body) {
- global $useSendmail;
- global $data_dir, $username, $domain, $key, $version, $sent_folder, $imapServerAddress;
+ function sendMessage($t, $c, $b, $subject, $body, $reply_id, $prio = 3) {
+ global $useSendmail, $msg_id, $is_reply, $mailbox, $onetimepad;
+ global $data_dir, $username, $domain, $key, $version, $sent_folder, $imapServerAddress, $imapPort;
+ global $default_use_priority;
+ global $more_headers;
+ $more_headers = Array();
+
+ do_hook("smtp_send");
+
+ $imap_stream = sqimap_login($username, $key, $imapServerAddress, $imapPort, 1);
+
+ if (isset($reply_id) && $reply_id) {
+ sqimap_mailbox_select ($imap_stream, $mailbox);
+ sqimap_messages_flag ($imap_stream, $reply_id, $reply_id, 'Answered');
+
+ // Insert In-Reply-To and References headers if the
+ // message-id of the message we reply to is set (longer than "<>")
+ // The References header should really be the old Referenced header
+ // with the message ID appended, but it can be only the message ID too.
+ $hdr = sqimap_get_small_header ($imap_stream, $reply_id, false);
+ if(strlen($hdr->message_id) > 2) {
+ $more_headers['In-Reply-To'] = $hdr->message_id;
+ $more_headers['References'] = $hdr->message_id;
+ }
+ }
+ if ($default_use_priority) {
+ $more_headers = array_merge($more_headers, createPriorityHeaders($prio));
+ }
+
+ // In order to remove the problem of users not able to create
+ // messages with "." on a blank line, RFC821 has made provision
+ // in section 4.5.2 (Transparency).
+ $body = ereg_replace("\n\\.", "\n..", $body);
+ $body = ereg_replace("^\\.", "..", $body);