Skip to content

Commit ef21916

Browse files
authored
Merge pull request #1755 from IrAlfred/add-bcc-field-to-saved-fields
feat(other): persist Bcc header in sent and draft messages
2 parents 25fe892 + 89346c3 commit ef21916

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

modules/imap/output_modules.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ class Hm_Output_filter_message_headers extends Hm_Output_Module {
183183
protected function output() {
184184
if ($this->get('msg_headers')) {
185185
$txt = '';
186-
$small_headers = array('subject', 'x-snoozed', 'date', 'from', 'to', 'reply-to', 'cc', 'flags');
186+
$small_headers = array('subject', 'x-snoozed', 'date', 'from', 'to', 'reply-to', 'cc', 'x-original-bcc', 'flags');
187187
$reply_args = sprintf('&list_path=%s&uid=%s',
188188
$this->html_safe($this->get('msg_list_path')),
189189
$this->html_safe($this->get('msg_text_uid'))
@@ -298,6 +298,9 @@ protected function output() {
298298
}
299299
$value = implode(', ', $new_value);
300300
}
301+
if (mb_strtolower($name) == 'x-original-bcc') {
302+
$name = 'Bcc';
303+
}
301304
$txt .= '<div class="row g-0 py-0 py-sm-1 small_header d-flex">';
302305
$txt .= '<div class="col-md-2"><span class="text-muted">'.$this->trans($name).'</span></div>';
303306
$txt .= '<div class="col-md-10 col-12 js-header_' . strtolower($name) . '">'.$this->html_safe($value).'</div>';

modules/smtp/hm-mime-message.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,16 @@ function set_auto_bcc($addr) {
129129
$this->headers['X-Auto-Bcc'] = 'cypht';
130130
}
131131

132+
function set_original_bcc_header() {
133+
if ($this->bcc) {
134+
$this->headers['X-Original-Bcc'] = $this->bcc;
135+
}
136+
}
137+
138+
function get_bcc() {
139+
return $this->bcc;
140+
}
141+
132142
function quote_fld($val) {
133143
if (!trim($val)) {
134144
return '';

modules/smtp/modules.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,10 @@ public function process() {
101101
$imap_draft['Cc'] = $this->unangle($msg_header['Cc']);
102102
}
103103

104+
if (array_key_exists('X-Original-Bcc', $msg_header)) {
105+
$imap_draft['Bcc'] = $this->unangle($msg_header['X-Original-Bcc']);
106+
}
107+
104108
if ($imap_draft) {
105109
recip_count_check($imap_draft, $this);
106110
$this->out('draft_id', $this->request->get['uid']);
@@ -769,6 +773,7 @@ public function process() {
769773

770774
/* check for associated IMAP server to save a copy */
771775
if ($imap_server !== false) {
776+
$mime->set_original_bcc_header();
772777
$this->out('save_sent_server', $imap_server, false);
773778
$this->out('save_sent_msg', $mime);
774779
}
@@ -1148,6 +1153,9 @@ protected function output() {
11481153
if (array_key_exists('Cc', $imap_draft)) {
11491154
$cc = $imap_draft['Cc'];
11501155
}
1156+
if (array_key_exists('Bcc', $imap_draft)) {
1157+
$bcc = $imap_draft['Bcc'];
1158+
}
11511159
if (array_key_exists('From', $imap_draft)) {
11521160
$from = $imap_draft['From'];
11531161
}
@@ -2035,6 +2043,8 @@ function prepare_draft_mime($atts, $uploaded_files, $from = false, $name = '', $
20352043
$profile_id
20362044
);
20372045

2046+
$mime->set_original_bcc_header();
2047+
20382048
$mime->add_attachments($uploaded_files);
20392049

20402050
return $mime;

0 commit comments

Comments
 (0)