phpdoc blocks
[squirrelmail.git] / src / read_body.php
index 1ac5cad1c85a4beef2adc9b0c9f82ec479d25cdb..bc267c6b1e91f3aff3461561e2aeb33dcd63ebe1 100644 (file)
  * the resulting emails in the right frame.
  *
  * $Id$
+ * @package squirrelmail
  */
 
-/* Path for SquirrelMail required files. */
+/** Path for SquirrelMail required files. */
 define('SM_PATH','../');
 
 /* SquirrelMail required files. */
@@ -142,7 +143,7 @@ function printer_friendly_link($mailbox, $passed_id, $passed_ent_id, $color) {
 
 function ServerMDNSupport($read) {
     /* escaping $ doesn't work -> \x36 */    
-    $ret = preg_match('/(\x36MDNSent|\\\*)/i', $read);
+    $ret = preg_match('/(\x36MDNSent|\\\\\*)/i', $read);
     return $ret;
 }
 
@@ -169,6 +170,16 @@ function SendMDN ( $mailbox, $passed_id, $sender, $message, $imapConnection) {
     $rfc822_header->to[] = $header->dnt;
     $rfc822_header->subject = _("Read:") . ' ' . encodeHeader($header->subject);
 
+    // Patch #793504 Return Receipt Failing with <@> from Tim Craig (burny_md)
+    // This merely comes from compose.php and only happens when there is no
+    // email_addr specified in user's identity (which is the startup config)
+    if (ereg("^([^@%/]+)[@%/](.+)$", $username, $usernamedata)) {
+       $popuser = $usernamedata[1];
+       $domain  = $usernamedata[2];
+       unset($usernamedata);
+    } else {
+       $popuser = $username;
+    }
 
     $reply_to = '';
     $ident = get_identities();
@@ -178,9 +189,9 @@ function SendMDN ( $mailbox, $passed_id, $sender, $message, $imapConnection) {
     $from_addr = '"'.$full_name.'" <'.$from_mail.'>';
     $reply_to  = $ident[$identity]['reply_to'];
 
-    if (!$from_addr) {
-       $from_addr = "$popuser@$domain";
-       $from_mail = $from_addr;
+    if (!$from_mail) {
+       $from_mail = "$popuser@$domain";
+       $from_addr = $from_mail;
     }
     $rfc822_header->from = $rfc822_header->parseAddress($from_addr,true);
     if ($reply_to) {
@@ -731,16 +742,11 @@ do_hook('html_top');
 
 if (isset($sendreceipt)) {
    if ( !$message->is_mdnsent ) {
-      if (isset($identity) ) {
-         $final_recipient = getPref($data_dir, $username, 'email_address' . '0', '' );
-      } else {
-         $final_recipient = getPref($data_dir, $username, 'email_address', '' );
-      }
-
-      $final_recipient = trim($final_recipient);
-      if ($final_recipient == '' ) {
-         $final_recipient = getPref($data_dir, $username, 'email_address', '' );
-      }
+      $final_recipient = '';
+      if ((isset($identity)) && ($identity != 0))      //Main identity
+         $final_recipient = trim(getPref($data_dir, $username, 'email_address' . $identity, '' ));
+      if ($final_recipient == '' )
+         $final_recipient = trim(getPref($data_dir, $username, 'email_address', '' ));
       $supportMDN = ServerMDNSupport($mbx_response["PERMANENTFLAGS"]);
       if ( SendMDN( $mailbox, $passed_id, $final_recipient, $message, $imapConnection ) > 0 && $supportMDN ) {
          ToggleMDNflag( true, $imapConnection, $mailbox, $passed_id, $uid_support);