From f22ea7ba1875863890b486db3e5f448f99c1debc Mon Sep 17 00:00:00 2001 From: alecpl Date: Thu, 7 Oct 2010 08:52:05 +0000 Subject: - Support SMTP Delivery Status Notifications - RFC3461 (#1486142) --- program/steps/mail/compose.inc | 23 +++++++++++++++++++++++ program/steps/mail/func.inc | 5 +++-- program/steps/mail/sendmail.inc | 8 +++++++- 3 files changed, 33 insertions(+), 3 deletions(-) (limited to 'program/steps/mail') diff --git a/program/steps/mail/compose.inc b/program/steps/mail/compose.inc index c1f491403..406033cb9 100644 --- a/program/steps/mail/compose.inc +++ b/program/steps/mail/compose.inc @@ -1174,6 +1174,28 @@ function rcmail_receipt_checkbox($attrib) } +function rcmail_dsn_checkbox($attrib) +{ + global $RCMAIL; + + list($form_start, $form_end) = get_form_tags($attrib); + unset($attrib['form']); + + if (!isset($attrib['id'])) + $attrib['id'] = 'dsn'; + + $attrib['name'] = '_dsn'; + $attrib['value'] = '1'; + $checkbox = new html_checkbox($attrib); + + $out = $form_start ? "$form_start\n" : ''; + $out .= $checkbox->show($RCMAIL->config->get('dsn_default')); + $out .= $form_end ? "\n$form_end" : ''; + + return $out; +} + + function rcmail_editor_selector($attrib) { global $CONFIG, $MESSAGE, $compose_mode; @@ -1251,6 +1273,7 @@ $OUTPUT->add_handlers(array( 'priorityselector' => 'rcmail_priority_selector', 'editorselector' => 'rcmail_editor_selector', 'receiptcheckbox' => 'rcmail_receipt_checkbox', + 'dsncheckbox' => 'rcmail_dsn_checkbox', 'storetarget' => 'rcmail_store_target_selection', )); diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc index aad127cfc..0fa22753d 100644 --- a/program/steps/mail/func.inc +++ b/program/steps/mail/func.inc @@ -1478,10 +1478,11 @@ function rcmail_compose_cleanup() * @param array $mailto Array of recipient address strings * @param array $smtp_error SMTP error array (reference) * @param string $body_file Location of file with saved message body (reference) + * @param array $smtp_opts SMTP options (e.g. DSN request) * * @return boolean Send status. */ -function rcmail_deliver_message(&$message, $from, $mailto, &$smtp_error, &$body_file) +function rcmail_deliver_message(&$message, $from, $mailto, &$smtp_error, &$body_file, $smtp_opts=null) { global $CONFIG, $RCMAIL; @@ -1525,7 +1526,7 @@ function rcmail_deliver_message(&$message, $from, $mailto, &$smtp_error, &$body_ if (!is_object($RCMAIL->smtp)) $RCMAIL->smtp_init(true); - $sent = $RCMAIL->smtp->send_mail($from, $a_recipients, $smtp_headers, $msg_body); + $sent = $RCMAIL->smtp->send_mail($from, $a_recipients, $smtp_headers, $msg_body, $smtp_opts); $smtp_response = $RCMAIL->smtp->get_response(); $smtp_error = $RCMAIL->smtp->get_error(); diff --git a/program/steps/mail/sendmail.inc b/program/steps/mail/sendmail.inc index a9ecf2ea2..da79c2f83 100644 --- a/program/steps/mail/sendmail.inc +++ b/program/steps/mail/sendmail.inc @@ -546,7 +546,13 @@ if (!$savedraft) $OUTPUT->send('iframe'); } - $sent = rcmail_deliver_message($MAIL_MIME, $from, $mailto, $smtp_error, $mailbody_file); + // Handle Delivery Status Notification request + if (!empty($_POST['_dsn'])) { + $smtp_opts['dsn'] = true; + } + + $sent = rcmail_deliver_message($MAIL_MIME, $from, $mailto, + $smtp_error, $mailbody_file, $smtp_opts); // return to compose page if sending failed if (!$sent) -- cgit v1.2.3