Skip to content

Commit

Permalink
deleting draft after successful compose form processing should be lim…
Browse files Browse the repository at this point in the history
…ited to imap drafts only and not real imap messages being replied to
  • Loading branch information
kroky authored and marclaporte committed Nov 7, 2022
1 parent 68239a7 commit 1695f99
Showing 1 changed file with 3 additions and 20 deletions.
23 changes: 3 additions & 20 deletions modules/smtp/modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -761,31 +761,14 @@ public function process() {
$this->out('msg_next_link', $form['next_email_post']);
}

# Delete draft after send
if ($form['draft_id'] > 0) {
$msg_path = explode('_', $this->request->post['compose_msg_path']);
$msg_uid = $this->request->post['compose_msg_uid'];

$imap = Hm_IMAP_List::connect($msg_path[1]);
if ($imap && $imap->select_mailbox(hex2bin($msg_path[2]))) {
$imap->message_action('DELETE', array($msg_uid));
$imap->message_action('EXPUNGE', array($msg_uid));
}
}

/* clean up */
$this->out('msg_sent', true);
Hm_Msgs::add("Message Sent");

/* if it is a draft, remove it */
if ($this->module_is_supported('imap') && $imap_server) {
$imap_server = find_imap_by_smtp(
$this->user_config->get('imap_servers'),
$this->user_config->get('smtp_servers')[$smtp_id]
);

$specials = get_special_folders($this, $imap_server['id']);
delete_draft($form['draft_id'], $this->cache, $imap_server['id'], $specials['draft']);
if ($this->module_is_supported('imap') && $imap_server && $form['draft_id'] > 0) {
$specials = get_special_folders($this, $imap_server);
delete_draft($form['draft_id'], $this->cache, $imap_server, $specials['draft']);
}

delete_uploaded_files($this->session, $form['draft_id']);
Expand Down

0 comments on commit 1695f99

Please sign in to comment.