From 09c1a5573cf5702e66bbb6f9873618c0187e592b Mon Sep 17 00:00:00 2001 From: Josaphat Imani Date: Wed, 31 Jan 2024 19:33:05 +0200 Subject: [PATCH] Added MDN to compose form --- modules/smtp/hm-smtp.php | 13 ++++++++++--- modules/smtp/modules.php | 12 ++++++++++-- modules/smtp/setup.php | 1 + 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/modules/smtp/hm-smtp.php b/modules/smtp/hm-smtp.php index d842ecb705..a2b003ce9f 100644 --- a/modules/smtp/hm-smtp.php +++ b/modules/smtp/hm-smtp.php @@ -522,17 +522,24 @@ function des_encrypt($string, $challenge='KGS!@#$%') { } /* Send a message */ - function send_message($from, $recipients, $message) { + function send_message($from, $recipients, $message, $from_params = '', $recipients_params = '') { $this->clean($from); - $command = 'MAIL FROM:<'.$from.'>'; + if ($from_params) { + $from_params = ' ' . $from_params; + } + $from_params = $from_params ? ' ' . $from_params : ''; + $command = 'MAIL FROM:<'.$from.'>' . $from_params; $this->send_command($command); $res = $this->get_response(); $bail = false; $result = 'An error occurred sending the message'; if(is_array($recipients)) { + if ($recipients_params) { + $recipients_params = ' ' . $recipients_params; + } foreach($recipients as $rcpt) { $this->clean($rcpt); - $command = 'RCPT TO:<'.$rcpt.'>'; + $command = 'RCPT TO:<'.$rcpt.'>'.$recipients_params; $this->send_command($command); $res = $this->get_response(); if ($this->compare_response($res, '250') != 0) { diff --git a/modules/smtp/modules.php b/modules/smtp/modules.php index 8afbd1d5c5..25e0654de8 100644 --- a/modules/smtp/modules.php +++ b/modules/smtp/modules.php @@ -668,6 +668,8 @@ public function process() { 'draft_subject' => $form['compose_subject'], 'draft_smtp' => $smtp_id ); + $from_params = ''; + $recipients_params = ''; /* parse attachments */ $uploaded_files = []; @@ -685,6 +687,11 @@ public function process() { /* msg details */ list($body, $cc, $bcc, $in_reply_to, $draft) = get_outbound_msg_detail($this->request->post, $draft, $body_type); + if ($this->request->post['compose_delivery_receipt']) { + $from_params = 'RET=HDRS'; + $recipients_params = 'NOTIFY=SUCCESS,FAILURE'; + } + /* smtp server details */ $smtp_details = Hm_SMTP_List::dump($smtp_id, true); if (!$smtp_details) { @@ -727,7 +734,7 @@ public function process() { } /* send the message */ - $err_msg = $smtp->send_message($from, $recipients, $mime->get_mime_msg()); + $err_msg = $smtp->send_message($from, $recipients, $mime->get_mime_msg(), $from_params, $recipients_params); if ($err_msg) { Hm_Msgs::add(sprintf("ERR%s", $err_msg)); repopulate_compose_form($draft, $this); @@ -1076,7 +1083,8 @@ protected function output() { '
'; + $this->html_safe($body).''. + '
'; if ($html == 2) { $res .= ''. ''. diff --git a/modules/smtp/setup.php b/modules/smtp/setup.php index 302736112a..6ff9569e27 100644 --- a/modules/smtp/setup.php +++ b/modules/smtp/setup.php @@ -162,6 +162,7 @@ 'compose_cc' => FILTER_UNSAFE_RAW, 'compose_bcc' => FILTER_UNSAFE_RAW, 'compose_smtp_id' => FILTER_SANITIZE_FULL_SPECIAL_CHARS, + 'compose_delivery_receipt' => FILTER_VALIDATE_BOOLEAN, 'draft_id' => FILTER_VALIDATE_INT, 'draft_body' => FILTER_UNSAFE_RAW, 'draft_subject' => FILTER_UNSAFE_RAW,