Sort out DSN functionality
authorpdontthink <pdontthink@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Wed, 13 Apr 2022 22:38:32 +0000 (22:38 +0000)
committerpdontthink <pdontthink@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Wed, 13 Apr 2022 22:38:32 +0000 (22:38 +0000)
git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@14946 7612ce4b-ef26-0410-bec9-ea0150e637f0

class/deliver/Deliver.class.php
class/mime/Rfc822Header.class.php
src/compose.php
src/read_body.php

index e3a4cd18e83500709eb5ece2528d21f81c46f7d0..403b88f3c785126c55a8d540062a3e8237bf1789 100644 (file)
@@ -741,6 +741,10 @@ class Deliver {
             /* RFC 2298 */
             $header[] = 'Disposition-Notification-To: '.$dnt. $rn;
         }
+        if ($rfc822_header->dsn) {
+            $dsn = $rfc822_header->getAddr_s('dsn');
+            $header[] = 'Return-Receipt-To: '.$dsn. $rn;
+        }
         if ($rfc822_header->priority) {
             switch($rfc822_header->priority)
             {
index aa990e6fd72ce955971d4cfa634a1cda4abe544b..c939766aad2ea817f5d5d0b4553795d1ff242f2c 100644 (file)
@@ -122,10 +122,10 @@ class Rfc822Header {
      */
     var $dnt = '';
     /**
-     * Delivery notification (DR)
+     * Address for requesting message delivery status notification (DSN)
      * @var mixed
      */
-    var $drnt = '';
+    var $dsn = '';
     /**
      * @var mixed
      */
@@ -289,7 +289,7 @@ class Rfc822Header {
                 break;
             case 'return-receipt-to':
                 $value = $this->stripComments($value);
-                $this->drnt = $this->parseAddress($value);
+                $this->dsn = $this->parseAddress($value);
                 break;
             case 'mime-version':
                 $value = $this->stripComments($value);
index c18d0ab98a8cffa0e82fdeddcd5bf46a8919a467..c3853dcbdf090760ed9126dd39b5a8cd658b56f8 100644 (file)
@@ -946,7 +946,7 @@ function newMail ($mailbox='', $passed_id='', $passed_ent_id='', $action='', $se
 
                 // Remember the receipt settings
                 $request_mdn = $mdn_user_support && !empty($orig_header->dnt) ? '1' : '0';
-                $request_dr = $mdn_user_support && !empty($orig_header->drnt) ? '1' : '0';
+                $request_dr = $mdn_user_support && !empty($orig_header->dsn) ? '1' : '0';
 
                 /* remember the references and in-reply-to headers in case of an reply */
 //FIXME: it would be better to fiddle with headers inside of the message object or possibly when delivering the message to its destination (drafts folder?); is this possible?
@@ -1771,10 +1771,9 @@ function deliverMessage(&$composeMessage, $draft=false) {
 
     /* Receipt: On Delivery */
     if (!empty($request_dr)) {
-//FIXME: it would be better to fiddle with headers inside of the message object or possibly when delivering the message to its destination; is this possible?
-        $rfc822_header->more_headers['Return-Receipt-To'] = $from_addr;
-    } elseif (isset($rfc822_header->more_headers['Return-Receipt-To'])) {
-        unset($rfc822_header->more_headers['Return-Receipt-To']);
+        $rfc822_header->dsn = $rfc822_header->parseAddress($from_addr,true);
+    } elseif (isset($rfc822_header->dsn)) {
+        unset($rfc822_header->dsn);
     }
 
     /* multipart messages */
index 9f04dcf2dae4086b7b1490590c29644330766d88..aeff2e7ee4000a95c0da41942c8a10744c64da67 100644 (file)
@@ -145,7 +145,10 @@ function SendMDN ( $mailbox, $passed_id, $message, $imapConnection) {
         $content_type->properties['charset']=$default_charset;
     }
     $rfc822_header->content_type = $content_type;
-    $rfc822_header->to[] = $header->dnt;
+    if (!empty($header->dnt))
+        $rfc822_header->to[] = $header->dnt;
+    else
+        $rfc822_header->to[] = $header->dsn;
     $rfc822_header->subject = _("Read:") . ' ' . decodeHeader($header->subject,true,false);
 
     $idents = get_identities();
@@ -410,7 +413,9 @@ function formatEnvheader($aMailbox, $passed_id, $passed_ent_id, $message,
 
     if ($default_use_mdn) {
         if ($mdn_user_support) {
-            if ($header->dnt) {
+            // We are generous to the sender because DSNs are commonly ignored by servers and
+            // technically offering a return receipt in the MUA for a DSN is overstepping the RFCs
+            if ($header->dnt || $header->dnt) {
                 $mdn_url = $PHP_SELF;
                 $mdn_url = set_url_var($mdn_url, 'mailbox', urlencode($mailbox));
                 $mdn_url = set_url_var($mdn_url, 'passed_id', $passed_id);