Bug 91252 - MDNs are not sent
Summary: MDNs are not sent
Status: RESOLVED FIXED
Alias: None
Product: kmail
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Gentoo Packages Linux
: NOR normal
Target Milestone: ---
Assignee: kdepim bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-10-13 17:17 UTC by BORGULYA Gábor
Modified: 2007-09-14 12:17 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
ignore settings and fake headers (1.98 KB, patch)
2007-01-21 00:14 UTC, Christian Schaarschmidt
Details
ignore settings; fake header fields and remove them later (2.02 KB, patch)
2007-02-03 17:25 UTC, Christian Schaarschmidt
Details

Note You need to log in before you can comment on or make changes to this bug.
Description BORGULYA Gábor 2004-10-13 17:17:34 UTC
Version:            (using KDE KDE 3.3.0)
Installed from:    Gentoo Packages
Compiler:          [GCC 3.3.3 20040412 (Gentoo Linux 3.3.3-r6, ssp-3.3.2-2, pie-8.7.6)] on linux2 
OS:                Linux

Despite my settings when I receive an email that requests an MDN KMail never send an MDN, it doesn't even ask if I want to send one (when setting it to "ask").
The "send MDN" filter action does nothing eithoer, although it reports no error.
Comment 1 BORGULYA Gábor 2006-10-16 15:25:54 UTC
With kmail 1.9.1 the situation is the same.
Comment 2 Michael Seiwert 2006-11-01 12:16:44 UTC
I can confirm this for 1.9.5 as well
Comment 3 BORGULYA Gábor 2006-11-06 10:45:13 UTC
Would it work if I used sendmail instead of POP and SMTP connections?
Comment 4 Christian Schaarschmidt 2007-01-21 00:11:41 UTC
I have tested it sending from/to Kmail 1.9.5 and 1.9.5+ and kmail asks politely what to do with the MDN request at least for incoming mails, for filter action see next comment.
Comment 5 Christian Schaarschmidt 2007-01-21 00:14:48 UTC
Created attachment 19356 [details]
ignore settings and fake headers

IMHO the send-fake-MDN-message filter action wont work as it is now. 
The filter action requires 
- MDN mode set to "always", batch mode does not allow to ask user
- Return-Path and Disposition-Notification-To headers must be available

I think if the users installs a filter to send fake messages we can ignore the
MDN setting and assume "always". To be on the save side, this could be an
option.

I guess if we fake the message we can as well fake the header fields
Return-Path and Disposition-Notification-To (this might break some standard,
haven't checked)
Comment 6 BORGULYA Gábor 2007-01-21 00:50:11 UTC
Thank you very much, Christian! I don't know how to compile kmail from the subversion repository, so I will wait until it appears in the newest gentoo package. I am looking forward to using the MDN feature! -- Gábor
Comment 7 Christian Schaarschmidt 2007-02-03 17:25:23 UTC
Created attachment 19523 [details]
ignore settings; fake header fields and remove them later
Comment 8 Christian Schaarschmidt 2007-02-05 20:49:43 UTC
SVN commit 630582 by schaarsc:

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


 M  +18 -0     branches/work/kdepim-3.5.5+/kmail/kmfilteraction.cpp  
 M  +23 -20    branches/work/kdepim-3.5.5+/kmail/kmmessage.cpp  


--- branches/work/kdepim-3.5.5+/kmail/kmfilteraction.cpp #630581:630582
@@ -118,11 +118,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/work/kdepim-3.5.5+/kmail/kmmessage.cpp #630581:630582
@@ -1465,27 +1465,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;
+    }
   }
 
 
Comment 9 Christian Schaarschmidt 2007-04-25 21:18:50 UTC
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;
+    }
   }