Skip to content

Commit b768681

Browse files
authored
fix(backend): ensure attachments are sent along when forwarding an email (#1407)
1 parent b593a0e commit b768681

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

modules/smtp/modules.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,11 @@ public function process() {
6666
if (array_key_exists(0, $msg_struct) && array_key_exists('subs', $msg_struct[0])) {
6767
foreach ($msg_struct[0]['subs'] as $ind => $sub) {
6868
if ($ind != '0.1') {
69-
$new_attachment['basename'] = $sub['description'];
70-
$new_attachment['name'] = $sub['description'];
69+
$new_attachment['basename'] = $sub['attributes']['name'];
70+
$new_attachment['name'] = $sub['attributes']['name'];
7171
$new_attachment['size'] = $sub['size'];
7272
$new_attachment['type'] = $sub['type'];
73-
$file_path = $this->config->get('attachment_dir').DIRECTORY_SEPARATOR.$new_attachment['name'];
73+
$file_path = $this->config->get('attachment_dir') . DIRECTORY_SEPARATOR . md5($this->session->get('username', false)) . DIRECTORY_SEPARATOR . $new_attachment['name'];
7474
$content = Hm_Crypt::ciphertext($imap->get_message_content($this->request->get['uid'], $ind), Hm_Request_Key::generate());
7575
file_put_contents($file_path, $content);
7676
$new_attachment['tmp_name'] = $file_path;
@@ -134,15 +134,16 @@ public function process() {
134134
if (array_key_exists(0, $msg_struct) && array_key_exists('subs', $msg_struct[0])) {
135135
foreach ($msg_struct[0]['subs'] as $ind => $sub) {
136136
if ($ind != '0.1') {
137-
$new_attachment['basename'] = $sub['description'];
138-
$new_attachment['name'] = $sub['description'];
137+
$new_attachment['basename'] = $sub['attributes']['name'];;
138+
$new_attachment['name'] = $sub['attributes']['name'];
139139
$new_attachment['size'] = $sub['size'];
140140
$new_attachment['type'] = $sub['type'];
141-
$file_path = $this->config->get('attachment_dir') . DIRECTORY_SEPARATOR . $new_attachment['name'];
141+
$file_path = $this->config->get('attachment_dir') . DIRECTORY_SEPARATOR . md5($this->session->get('username', false)) . DIRECTORY_SEPARATOR . $new_attachment['name'];
142142
$content = Hm_Crypt::ciphertext($imap->get_message_content($this->request->get['uid'], $ind), Hm_Request_Key::generate());
143143
file_put_contents($file_path, $content);
144144
$new_attachment['tmp_name'] = $file_path;
145145
$new_attachment['filename'] = $file_path;
146+
$new_attachement['sub'] = json_encode($sub);
146147
$attached_files[$this->request->get['uid']][] = $new_attachment;
147148
}
148149
}

0 commit comments

Comments
 (0)