I'm experiencing and have been investigating the bugs
https://bugs.kde.org/show_bug.cgi?id=379539 = SMTP fails with "the proxy type is invalid for this operation"
https://bugs.kde.org/show_bug.cgi?id=373870 = Kmail tries to use a proxy server to retrieve email
and suspect that they have the same root cause. My setup has the KDE proxy settings to use environment variables, and http_proxy and ssl_proxy set to use a Privoxy proxy. The environment variable setup is used because anything based on QtWebEngine can only use a proxy specified that way - it cannot use the KDE settings.
This works fine for web browsing, but from the Privoxy logs and network traffic it appears that POP3 fetching and SMTP sending is also trying to go through the proxy. This works with Privoxy, it just passes the traffic through, but it may not work with other proxies or caches.
The obvious solution of setting no_proxy to cover the POP3/SMTP hosts doesn't work, the network access does not resolve this correctly and fails with an error deep within QNativeSocketEngine. My suspicion is either a problem in Qt networking, or an anomaly because QT's parsing of no_proxy is different to KIO's (KIO seems to be more sophisticated).
Trying to fix this, deep within the bowels of either KIO or QtNetwork, has the potential to affect lots of networking code and is a risky solution. The other solution that I have found is to explicitly set a QNetworkProxy::NoProxy application proxy in the POP3 ioslave and the KSmtp session thread. This correctly bypasses the proxy regardless of the setting of no_proxy.
Some users may need to access these services via a proxy, so it should be a configurable option (off by default), a single check box added to the "Advanced" tab of these account setups (in the group box that has "Encryption", "Port" etc).
Unless anyone has ideas on a better solution, I'll tidy up the code that I have so far and start to submit reviews.
This may also need to be done for IMAP.