Bug 373870

Summary: Kmail tries to use a proxy server to retrieve email
Product: [Applications] kmail2 Reporter: Kwanza.Pili
Component: generalAssignee: kdepim bugs <kdepim-bugs>
Status: RESOLVED FIXED    
Severity: normal CC: jjm, marlos.mc, pard, wbauer
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Linux   
See Also: https://bugs.kde.org/show_bug.cgi?id=407685
Latest Commit: Version Fixed In:

Description Kwanza.Pili 2016-12-18 22:49:08 UTC
The latest version of Kmail2 5.4.0 tries to use my squid proxy server to retrieve email, which of course fails because squid cannot handle imaps/pop3s protocols. I can see this in my squid logs which has entries like " ... TCP_DENIED/403 3853 CONNECT imap.gmail.com:993 - HIER_NONE/- text/html". So I specifically added imap.gmail.com to the exception list in the NO_PROXY environment variable. Now Kmail merely hangs in offline mode and can never comment to the any mail server I specify. Just to clear, I can connect to the mail servers using webmail (e.g. via firefox). 

Earlier versions of kmail did not exhibit this behaviour. They would not use to use the proxy settings for konqueror and simply bypassed the proxy server. I noticed that another mail client (geary) also has the habit of using the proxy environments, but it then behaves well if the exceptions are set. Kmail does not. 

My kde components are mainly compiled from source under OpenSUSE 42.2. The versions are:
- kmail2 5.4.0 from kmail-16.12.0
- Plasma 5.8.4
- Frameworks 5.28.0

Thanks.
Comment 1 pard 2017-01-07 16:16:11 UTC
Same behavior at me.
Comment 2 Jonathan Marten 2017-11-08 20:31:21 UTC
Confirmed with current Git master.
Suspect same root cause as bug 379539.
Comment 3 Kwanza.Pili 2018-01-17 16:01:15 UTC
I have changed to kmail version 5.7.1 (KDE 17.12.1) and the problem persists. I think the following error messages might point to the source of the problem:
---
kf5.kio.core: Refilling KProtocolInfoFactory cache in the hope to find "smtp"
org.kde.pim.mailtransport: Transport with this ID not managed by transport manager.
---

I figured out that kmail uses the proxy server to reach SMTP servers, and mine (squid) was blocking this from going through. So I had to add a whitelist of servers to the squid configuration: e.g. 
---
http_access allow whitelist
http_access allow CONNECT whitelist
---
where whitelist is the acl for the servers. This might be potentially risky, but it is the only workaround I could find.
Comment 4 Jonathan Marten 2018-03-02 14:31:01 UTC
Fixed by https://phabricator.kde.org/D10317 and https://phabricator.kde.org/D10318 for POP3.  Needs to be investigated for IMAP.
Comment 5 Kwanza.Pili 2018-09-30 18:16:28 UTC
Superseeded by the current releases.
Comment 6 Marlos 2019-05-22 14:16:23 UTC
I still have this issue for kmail 5.10.2 (Fedora 30), with imap protocol. After a lot of tests, it seems kmail gets http_proxy variable value from environment and use it for imap connections.
Comment 7 Wolfgang Bauer 2019-05-23 13:22:45 UTC
(In reply to Marlos from comment #6)
> I still have this issue for kmail 5.10.2 (Fedora 30), with imap protocol.
> After a lot of tests, it seems kmail gets http_proxy variable value from
> environment and use it for imap connections.

There is another bug report about this, and a fix has been proposed.
See bug#407685.
Comment 8 Wolfgang Bauer 2019-05-23 13:24:40 UTC
(In reply to Wolfgang Bauer from comment #7)
> and a fix has been proposed.
Sorry, not yet it seems.
Comment 9 Jonathan Marten 2019-05-28 15:48:02 UTC
Reviews submitted, see bug 407685.
Comment 10 Jonathan Marten 2019-06-19 07:15:27 UTC
Fix now complete for POP3, SMTP and IMAP.