[Bug 91252] MDNs are not sent

Christian Schaarschmidt <[email protected]>
Newsgroups gmane.comp.kde.devel.kmail
Message-ID <[email protected]>
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
         
http://bugs.kde.org/show_bug.cgi?id=91252         
schaarsc gmx de changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED



------- Additional Comments From schaarsc gmx de  2007-04-25 21:18 -------
SVN commit 658035 by schaarsc:

port 630582
in KMime::MDN::AutomaticAction mode ignore MDN user settings
fake header fields if missing and remove them later.
BUG:91252


 M  +18 -0     kmfilteraction.cpp  
 M  +23 -20    kmmessage.cpp  


--- branches/KDE/3.5/kdepim/kmail/kmfilteraction.cpp #658034:658035
 @ -115,11 +115,29  @
 void KMFilterAction::sendMDN( KMMessage * msg, KMime::MDN::DispositionType d,
                               const QValueList<KMime::MDN::DispositionModifier> & m ) {
   if ( !msg ) return;
+
+  /* createMDN requires Return-Path and Disposition-Notification-To
+   * if it is not set in the message we assume that the notification should go to the
+   * sender
+   */
+  const QString returnPath = msg->headerField( "Return-Path" );
+  const QString dispNoteTo = msg->headerField( "Disposition-Notification-To" );
+  if ( returnPath.isEmpty() )
+    msg->setHeaderField( "Return-Path", msg->from() );
+  if ( dispNoteTo.isEmpty() )
+    msg->setHeaderField( "Disposition-Notification-To", msg->from() );
+
   KMMessage * mdn = msg->createMDN( KMime::MDN::AutomaticAction, d, false, m );
   if ( mdn && !kmkernel->msgSender()->send( mdn, KMail::MessageSender::SendLater ) ) {
     kdDebug(5006) << "KMFilterAction::sendMDN(): sending failed." << endl;
     //delete mdn;
   }
+
+  //restore orignial header
+  if ( returnPath.isEmpty() )
+    msg->removeHeaderField( "Return-Path" );
+  if ( dispNoteTo.isEmpty() )
+    msg->removeHeaderField( "Disposition-Notification-To" );
 }
 
 
--- branches/KDE/3.5/kdepim/kmail/kmmessage.cpp #658034:658035
 @ -1435,27 +1435,30  @
     s = MDN::SentManually;
   }
 
-  if ( mode == 1 ) { // ask
-    if ( !allowGUI ) return 0; // don't setMDNSentState here!
-    mode = requestAdviceOnMDN( "mdnNormalAsk" );
-    s = MDN::SentManually; // asked user
-  }
+  if ( a != KMime::MDN::AutomaticAction ) { 
+    //TODO: only ingore user settings for AutomaticAction if requested 
+    if ( mode == 1 ) { // ask
+      if ( !allowGUI ) return 0; // don't setMDNSentState here!
+      mode = requestAdviceOnMDN( "mdnNormalAsk" );
+      s = MDN::SentManually; // asked user
+    }
 
-  switch ( mode ) {
-  case 0: // ignore:
-    setMDNSentState( KMMsgMDNIgnore );
-    return 0;
-  default:
-  case 1:
-    kdFatal(5006) << "KMMessage::createMDN(): The \"ask\" mode should "
-		  << "never appear here!" << endl;
-    break;
-  case 2: // deny
-    d = MDN::Denied;
-    m.clear();
-    break;
-  case 3:
-    break;
+    switch ( mode ) {
+      case 0: // ignore:
+        setMDNSentState( KMMsgMDNIgnore );
+        return 0;
+      default:
+      case 1:
+        kdFatal(5006) << "KMMessage::createMDN(): The \"ask\" mode should "
+                                                  << "never appear here!" << endl;
+        break;
+      case 2: // deny
+        d = MDN::Denied;
+        m.clear();
+        break;
+      case 3:
+        break;
+    }
   }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.