+if ($default_use_mdn) {
+ if ($mdn_user_support) {
+
+ // debug gives you the capability to remove mdn-flags
+ $debug = false;
+ $read = sqimap_run_command ($imapConnection, "FETCH $passed_id BODY.PEEK[HEADER.FIELDS (Disposition-Notification-To)]", true,
+ $response, $readmessage);
+ $MDN_to = substr($read[1], strpos($read[1], ' '));
+ $MDN_flag_present = false;
+
+ $read = sqimap_run_command ($imapConnection, "FETCH $passed_id FLAGS", true,
+ $response, $readmessage);
+
+ $MDN_flag_present = preg_match( '/.*\$MDNSent/i', $read[0]);
+
+ if (trim($MDN_to) &&
+ (!isset( $sendreceipt ) || $sendreceipt == '' ) ) {
+
+ if ( $MDN_flag_present && $supportMDN) {
+ $sendreceipt = 'removeMDN';
+ $url = "\"read_body.php?mailbox=$mailbox&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more&sendreceipt=$sendreceipt\"";
+ $sendreceipt="";
+ if ($debug ) {
+ echo '<TR>' .
+ "<TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>" .
+ _("Read receipt") . ': ' .
+ "</TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>" .
+ '<B>' .
+ _("send") .
+ "</B> <a href=$url>[" . _("Remove MDN flag") . '] </a>' .
+ '</TD>' .
+ '</TR>' . "\n";
+ } else {
+ echo '<TR>' .
+ "<TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>" .
+ _("Read receipt") . ': ' .
+ "</TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>" .
+ '<B>'._("send").'</B>'.
+ '</TD>' .
+ '</TR>' . "\n";
+ }
+
+ } // when deleted or draft flag is set don't offer to send a MDN response
+ else if ( ereg('Draft',$read[0] || ereg('Deleted',$read[0])) ) {
+ echo '<TR>' .
+ "<TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>" .
+ _("Read receipt") . ': '.
+ "</TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>" .
+ '<B>' . _("requested") . "</B>" .
+ '</TD>' .
+ '</TR>' . "\n";
+ }
+ // if no MDNsupport don't use the annoying popup messages
+ else if ( !$FirstTimeSee ) {
+ $sendreceipt = 'send';
+ $url = "\"read_body.php?mailbox=$mailbox&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more&sendreceipt=$sendreceipt\"";
+ echo '<TR>' .
+ "<TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>" .
+ _("Read receipt") . ': ' .
+ "</TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>" .
+ '<B>' . _("requested") .
+ "</B> <a href=$url>[" . _("Send read receipt now") . "]</a>" .
+ '</TD>' .
+ '</TR>' . "\n";
+ $sendreceipt='';
+ }
+ else {
+ $sendreceipt = 'send';
+ $url = "\"read_body.php?mailbox=$mailbox&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more&sendreceipt=$sendreceipt\"";
+ if ($javascript_on) {
+ echo "<script language=\"javascript\"> \n" .
+ '<!-- ' . "\n" .
+ " if (window.confirm(\"" .
+ _("The message sender has requested a response to indicate that you have read this message. Would you like to send a receipt?") .
+ "\")) { \n" .
+ " window.location=($url); \n" .
+ ' window.reload()' . "\n" .
+ ' }' . "\n" .
+ '// -->' . "\n" .
+ '</script>' . "\n";
+ }
+ echo '<TR>' .
+ "<TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>" .
+ _("Read receipt") . ': ' .
+ "</TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>" .
+ '<B>' . _("requested") . "  </B><a href=$url>" . '[' .
+ _("Send read receipt now") . '] </a>' ." \n" .
+ '</TD>' .
+ '</TR>' . "\n";
+ $sendreceipt = '';
+ }
+ }
+
+ if ( !isset( $sendreceipt ) || $sendreceipt == '' ) {
+ } else if ( $sendreceipt == 'send' ) {
+ if ( !$MDN_flag_present) {
+ 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', '' );
+ }
+
+ if ( SendMDN( $MDN_to, $final_recipient ) > 0 && $supportMDN ) {
+ ToggleMDNflag( true);
+ }
+ }
+ $sendreceipt = 'removeMDN';
+ $url = "\"read_body.php?mailbox=$mailbox&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more&sendreceipt=$sendreceipt\"";
+ $sendreceipt="";
+
+ if ($debug && $supportMDN) {
+ echo " <TR>\n" .
+ " <TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>\n" .
+ " "._("Read receipt").": \n".
+ " </TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>\n" .
+ ' <B>'._("send").'</B>'." <a href=$url>" . '[' . _("Remove MDN flag") . '] </a>' . "\n" .
+ ' </TD>' . "\n" .
+ ' </TR>' . "\n";
+ } else {
+ echo " <TR>\n" .
+ " <TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>\n" .
+ " "._("Read receipt").": \n".
+ " </TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>\n" .
+ ' <B>'._("send").'</B>'. "\n" .
+ ' </TD>' . "\n" .
+ ' </TR>' . "\n";
+ }
+ }
+ elseif ($sendreceipt == 'removeMDN' ) {
+ ToggleMDNflag ( false );
+
+ $sendreceipt = 'send';
+ $url = "\"read_body.php?mailbox=$mailbox&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more&sendreceipt=$sendreceipt\"";
+ echo '<TR>'.
+ "<TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>" .
+ _("Read receipt") . ': ' .
+ "</TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>" .
+ '<B>' . _("requested") .
+ "</B> <a href=$url>[" . _("Send read receipt now") . "]</a>" .
+ '</TD>' .
+ '</TR>' . "\n";
+ $sendreceipt = '';
+
+ }
+ }
+}
+
+do_hook('read_body_header');
+