Skip to content

Commit

Permalink
Merge pull request #703 from josaphatim/mdn-dsn
Browse files Browse the repository at this point in the history
Added MDN/SDN to compose form
  • Loading branch information
kroky authored Feb 1, 2024
2 parents 1824da8 + 09c1a55 commit 056a74b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
13 changes: 10 additions & 3 deletions modules/smtp/hm-smtp.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
12 changes: 10 additions & 2 deletions modules/smtp/modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,8 @@ public function process() {
'draft_subject' => $form['compose_subject'],
'draft_smtp' => $smtp_id
);
$from_params = '';
$recipients_params = '';

/* parse attachments */
$uploaded_files = [];
Expand All @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -1076,7 +1083,8 @@ protected function output() {
'<div id="bcc_contacts"></div></div></div><input value="'.$this->html_safe($subject).
'" name="compose_subject" class="compose_subject" type="text" placeholder="'.
$this->trans('Subject').'" /><textarea id="compose_body" name="compose_body" class="compose_body">'.
$this->html_safe($body).'</textarea>';
$this->html_safe($body).'</textarea>'.
'<div><input value="1" name="compose_delivery_receipt" id="compose_delivery_receipt" type="checkbox" /><label for="compose_delivery_receipt">'.$this->trans('Request a delivery receipt').'</label></div>';
if ($html == 2) {
$res .= '<link href="'.WEB_ROOT.'modules/smtp/assets/markdown/editor.css" rel="stylesheet" />'.
'<script type="text/javascript" src="'.WEB_ROOT.'modules/smtp/assets/markdown/editor.js"></script>'.
Expand Down
1 change: 1 addition & 0 deletions modules/smtp/setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 056a74b

Please sign in to comment.