Bug 49902

Summary: KMail loses/confuses TLS settings
Product: [Applications] kmail Reporter: George Staikos <staikos>
Component: generalAssignee: kdepim bugs <kdepim-bugs>
Status: RESOLVED FIXED    
Severity: grave    
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Linux   
Latest Commit: Version Fixed In:

Description George Staikos 2002-10-30 00:10:58 UTC
Version:            (using KDE Devel)
Installed from:    Compiled sources
Compiler:          gcc 2.95.3 
OS:          Linux

There seems to be a bug in KMail right now, and I would personally consider 
it to be a "show stopper".  I say this because I dont' fully understand it, 
but it seems to lose track of the TLS setting.  This could potentially be 
very bad.  While it is actually to strong in my case, I wonder if in other 
cases it might be too weak.  Here is how it is reproduced for me:

Launch kmail and use it only with identities that use TLS (for SMTP, POP3).  
Then try to send an email from an identity that doesn't use TLS.  In my case, 
this is because this server doesn't support TLS or SSL.  However KMail 
insists on using TLS, even though the configuration for the identity does not 
have TLS checked.  The result is a message box that says that TLS is not 
supported on the remote server.  If I shut down KMail, restart, then try 
resending before doing anything that uses TLS, it sends without any problems.

I have reproduced this problem several times now.  However I haven't done it 
in such smooth fashion as I descibe above, simply because I haven't 
investigated so far yet.  I just know that is what happened so far on several 
occasions.
Comment 1 Ingo Klöcker 2002-10-31 01:07:11 UTC
Subject: Re:  New: KMail loses/confuses TLS settings

As I already wrote in a reply to George's message to kde-core-devel and 
kmail I think the bug is in the SMTP kioslave and not in KMail.

Regards,
Ingo


Comment 2 George Staikos 2003-03-10 06:03:01 UTC
Ok I have diagnosed this.  Here's how it works: 
 
1) Send an email with an SMTP account that has TLS enabled. 
2) Send an email with an outbound account of smtp://host  (note nothing else 
there), to a host that doesn't support TLS. 
 
It will fail saying that TLS is not supported. 
 
Here is what the second SMTP (non-TLS) server says: 
 
220 tomts24.bellnexxia.net ESMTP server (InterMail vM.5.01.04.19 
201-253-122-122-119-20020516) ready Mon, 10 Mar 2003 00:00:11 -0500 
EHLO 0 
250-tomts24-srv.bellnexxia.net 
250-HELP 
250-PIPELINING 
250-DSN 
250-8BITMIME 
250 SIZE 10485760 
EHLP 
500 Command unknown: 'EHLP' 
HELP 
214-This SMTP server is a part of the InterMail E-mail system.  For 
214-information about InterMail, please see http://www.software.com 
214- 
214-      Supported commands: 
214- 
214-           EHLO     HELO     MAIL     RCPT     DATA 
214-           VRFY     RSET     NOOP     QUIT 
214- 
214-      SMTP Extensions supported through EHLO: 
214- 
214-           EXPN     HELP     SIZE 
214- 
214-For more information about a listed topic, use "HELP <topic>" 
214 Please report mail-related problems to Postmaster at this site. 
 
 
Is it possible that there is a variable not getting reinitialised in kio_smtp? 
 
Comment 3 George Staikos 2003-03-10 07:16:44 UTC
Subject: kdepim/kmail

CVS commit by staikos: 

So I fix my own bug reports I guess.
Properly determine SSL/TLS state for non-transport sending (ie using a URL
such as smtp://)

CCMAIL: 49902-done@bugs.kde.org


  M +21 -4     kmsender.cpp   1.171


--- kdepim/kmail/kmsender.cpp  #1.170:1.171
@@ -562,11 +562,28 @@ KMSendProc* KMSender::createSendProcFrom
       mTransportInfo->type = "smtp";
       mTransportInfo->auth = FALSE;
+      mTransportInfo->encryption = "NONE";
       QString serverport = transport.mid(7);
+      int colon = serverport.find(':');
+      if (colon != -1) {
+        mTransportInfo->host = serverport.left(colon);
+        mTransportInfo->port = serverport.mid(colon + 1);
+      } else {
       mTransportInfo->host = serverport;
       mTransportInfo->port = "25";
+      }
+    } else
+    if (transport.startsWith("smtps://"))
+    {
+      mTransportInfo->type = "smtps";
+      mTransportInfo->auth = FALSE;
+      mTransportInfo->encryption = "ssl";
+      QString serverport = transport.mid(7);
       int colon = serverport.find(':');
       if (colon != -1) {
         mTransportInfo->host = serverport.left(colon);
         mTransportInfo->port = serverport.mid(colon + 1);
+      } else {
+        mTransportInfo->host = serverport;
+        mTransportInfo->port = "465";
       }
     }
@@ -580,8 +597,8 @@ KMSendProc* KMSender::createSendProcFrom
   if (mTransportInfo->type == "sendmail")
     return new KMSendSendmail(this);
-  if (mTransportInfo->type == "smtp")
+  if (mTransportInfo->type == "smtp" || mTransportInfo->type == "smtps")
     return new KMSendSMTP(this);
 
-  return 0;
+  return 0L;
 }