Bug 387926 - Release version 17.12: Sending a mail with SMTP fails with: org.kde.pim.ksmtp: Socket error: 1
Summary: Release version 17.12: Sending a mail with SMTP fails with: org.kde.pim.ksmtp...
Status: RESOLVED FIXED
Alias: None
Product: Akonadi
Classification: Frameworks and Libraries
Component: Mail Dispatcher Agent (show other bugs)
Version: unspecified
Platform: Gentoo Packages Linux
: NOR grave
Target Milestone: ---
Assignee: kdepim bugs
URL:
Keywords:
: 388005 (view as bug list)
Depends on:
Blocks:
 
Reported: 2017-12-15 09:42 UTC by Jan-Matthias Braun
Modified: 2018-01-08 14:40 UTC (History)
22 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jan-Matthias Braun 2017-12-15 09:42:55 UTC
When trying to send an e-Mail since trying out the 17.12 pre-releases, I am unable to send e-Mails. In the official release, I have now recreated the SMTP but the problem persists, no mail gets out.

The only debug message I am seeing after enabling diverse output in kdebugdialog5 is
org.kde.pim.ksmtp: Socket error: 1
Comment 1 Jan-Matthias Braun 2017-12-15 09:46:30 UTC
Further tests with another account revealed, that sending via the EWS resource works.

So does sending via a local mail dispatcher, like ssmtp or nullmailer. Although akonadi/kmail2 seems to run into problems with sendmail compatibility issues of those.
Comment 2 Jan-Matthias Braun 2017-12-15 09:49:15 UTC
For another account using SMTP, I am seeing another error in the notification widget. Instead of getting a "1", as for the original report, I am seeing "Serverfehler", the German translation of Server error, in the notification window, but unluckily no debug output in the terminal.
Comment 3 markuss 2017-12-18 13:01:33 UTC
*** Bug 388005 has been marked as a duplicate of this bug. ***
Comment 4 Christophe Marin 2017-12-18 13:03:51 UTC
Not enough information : 

- which smtp servers were tested ?
- which authentication method ?
- was it a plain text / html message ? Did it contain attachments ?
Comment 5 jread 2017-12-18 14:05:12 UTC
I have a problem sending mail too.  I am using Antergos and have just updated to KMail 17.12 this morning.

It fails using GMail and also my own hosted server for my business running Postfix/Dovecot.

I have tried sending a plain text message with no attachments.  My own server authenticates using STARTTLS on port 587, I believe my GMail is using SSL on port 465.

My mail.log file just reports that the connection was lost after STARTTLS.
Comment 6 Rex Dieter 2017-12-18 14:19:48 UTC
For an extra data point, setting up a new google account after kmail-17.12.0 installation seems fine (for me, on my fedora 27 box)
Comment 7 Daniel Vrátil 2017-12-18 14:31:58 UTC
Socket Error 1 is ConnectionRefusedError, which means it's a problem on the server. Have you checked your SSL/TLS/port settings?
Comment 8 jread 2017-12-18 14:38:35 UTC
My error is not a socket error but a connection interrupted error, but this bug is linked from bug 387926 which is closed as resolved.

My laptop with 17.08 on still works absolutely fine
Comment 9 jread 2017-12-18 14:39:46 UTC
(In reply to jread from comment #8)
> My error is not a socket error but a connection interrupted error, but this
> bug is linked from bug 387926 which is closed as resolved.
> 
> My laptop with 17.08 on still works absolutely fine

Sorry incorrect bug, I referenced this one.

I meant Bug 388005
Comment 10 dcg 2017-12-18 16:26:54 UTC
I got an error too.

I fixed it by going to the outgoing account configuration -> advanced, then click "autodetect". It changed my cypher option from SSL to TLS and also the port. That made it work.

It's as if the configuration had been changed or something.
Comment 11 David E. Narvaez 2017-12-18 21:18:16 UTC
(In reply to dcg from comment #10)
> I fixed it by going to the outgoing account configuration -> advanced, then
> click "autodetect". It changed my cypher option from SSL to TLS and also the
> port. That made it work.
> 
> It's as if the configuration had been changed or something.

I can confirm this workaround. I don't understand why would the settings change after an update.
Comment 12 Urs Joss 2017-12-18 22:55:06 UTC
Same here:

Archlinux. Failing to send to mail.gmx.net with the previously working configuration SSL/Plain on port 465, with or without attachment.

In my case I had to switch to TLS and port 587 to get it back up.

Interestingly the autodetect option switches back to SSL/465 and removes the tick in checkbox 'server requires authentication'. I don't know how the previous version of kmail behaved with this functionality, I haven't used it for quite some time.
Comment 13 tromzy 2017-12-19 08:37:21 UTC
The "Autodetect" workaround does not work on my end.
Comment 14 jread 2017-12-19 08:47:12 UTC
Autodetect fix doesn't change anything for me as KMail connects with my server then drops the connection, so that isn't the issue.
Comment 15 Zoran Dimovski 2017-12-19 15:52:10 UTC
The same issue tested on 4 different machines (one Manjaro, 3 KDE neon).
After the upgrade nobody could send emails when the outgoing account was using SSL connection.

Tested all the auth methods with SSL, you can't send email.

On the server side, these are the enable auth methods:
250-AUTH PLAIN LOGIN CRAM-MD5 DIGEST-MD5 GSSAPI

The Message on the server side when I try to send email:
SMTP-IN:002DB307: Authentication error: Generic error
SMTP-IN:002DB307: >> 535 Authentication failed
- or
SMTP-IN:002DB262: Authentication error: Account not found locally
SMTP-IN:002DB262: >> 535 Authentication failed

depending on the auth method.

Only GSSAPI has a different error:
421 mailserver.hostname error reading data

My current workaround is _not_ using encryption (port 25, LOGIN or PLAIN auth).

When using TLS I get a popup windows with this info:
The server failed the authenticity check (mailserver.hostname).
The certificate does not apply to the given host
The certificate is not signed by any trusted certificate authority
The certificate has expired

But the certificate is fine, for that host, signed and 2 years more to go.
Comment 16 Alex Sidorenko 2017-12-20 14:14:42 UTC
Same here - Gmail sending stopped work after upgrade to 17.12 (Ubuntu/Neon)
Comment 17 Alex Sidorenko 2017-12-20 14:21:48 UTC
(In reply to Alex Sidorenko from comment #16)
> Same here - Gmail sending stopped work after upgrade to 17.12 (Ubuntu/Neon)

My settings were based on 'Autodetect', SSL on port 465. After I changed this manually to TLS/587, sending email works
Comment 18 stefanprobst 2017-12-20 17:22:47 UTC
SMTP does not work here either. Error: org.kde.pim.ksmtp: Socket error: 2.
Changing SSL to TLS did not help.
Comment 19 Frank Noack 2017-12-21 17:43:29 UTC
Please check the used port and restart akonadi. Then is should work. Trying to send e-mail via ssl increases the processor load by akonadi and mysql extremely.
Comment 20 Rewarp 2017-12-22 01:54:02 UTC
OS: openSUSE TUmbleweed
Version: 5.7

I can confirm all my smtp settings are correct for Fastmail and Office365 and yet only my Google SMTP sends my messages.

smtp.office365.com
TLS; 587;LOGIN

smtp.fastmail.com
TLS; 465; PLAIN

smtp.googlemail.com
TLS; 25; LOGIN
Comment 21 Rewarp 2017-12-22 06:07:01 UTC
I restarted akonadi and see this error too:

org.kde.pim.ksmtp: Socket error: 2
Comment 22 Frank Noack 2017-12-22 07:16:51 UTC
Please try port 587 with fastmail
Comment 23 SFA 2017-12-22 10:08:53 UTC
*** This bug has been confirmed by popular vote. ***
Comment 24 SFA 2017-12-22 10:10:36 UTC
Confirmed in TUMBLEWEED
Not able to post emails thru SMTP anymore with SSL/LTS and this is a requirement from my provider.

Restarted everything, from akonadictl to kmail, laptop, etc, etc.

Message from akonadictl : 
org.kde.pim.ksmtp: Socket error: 2
Comment 25 Rewarp 2017-12-22 10:42:53 UTC
Changing the port for Fastmail to 587 fails to get smtp working.
Comment 26 Rewarp 2017-12-22 11:04:10 UTC
Quick update. Emails now sent from Fastmail following port number change, but about half an hour after they were supposed to be sent.
Comment 27 Frank Noack 2017-12-22 12:20:23 UTC
The patch from  https://phabricator.kde.org/D9476 solves the ssl problem for me.
Comment 28 kzi 2017-12-22 14:16:35 UTC
I can confirm the issue on Tumbleweed, KMail 5.7.0, server mail.snafu.de port 25 or 587. Encryption 'None' or TLS results in Socket error: 2, while SSL gives Socket error: 9. TLS/25/PLAIN is autodetected. Provider says 'SSL' (but probably means TLS) and above ports.

The ksmtp patch 17.12.0-3-1 rolled out today noon UTC:
- Add patch to fix sending of emails over SSL (without STARTTLS):
  * 0001-Fix-duplicate-authentication.patch
  * Fixes kde#388068, kde#387926 and boo#1073975

does ***NOT*** fix this issue for me.
Comment 29 Christophe Marin 2017-12-22 14:32:05 UTC
(In reply to kzi from comment #28)
> I can confirm the issue on Tumbleweed, KMail 5.7.0, server mail.snafu.de
> port 25 or 587. Encryption 'None' or TLS results in Socket error: 2, while
> SSL gives Socket error: 9. TLS/25/PLAIN is autodetected. Provider says 'SSL'
> (but probably means TLS) and above ports.
> 
Different issue, please open a new bug report.
Comment 30 Fabian Vogt 2017-12-22 20:21:23 UTC
(In reply to kzi from comment #28)
> I can confirm the issue on Tumbleweed, KMail 5.7.0, server mail.snafu.de
> port 25 or 587. Encryption 'None' or TLS results in Socket error: 2, while
> SSL gives Socket error: 9. TLS/25/PLAIN is autodetected. Provider says 'SSL'
> (but probably means TLS) and above ports.
> 
> The ksmtp patch 17.12.0-3-1 rolled out today noon UTC:
> - Add patch to fix sending of emails over SSL (without STARTTLS):
>   * 0001-Fix-duplicate-authentication.patch
>   * Fixes kde#388068, kde#387926 and boo#1073975
> 
> does ***NOT*** fix this issue for me.

It is indeed a different issue, but it's fairly simple: ksmtp sends the server's hostname instead of the local hostname by accident with the "EHLO" command.
The mail.snafu.de server rejects that immediately, but example.com works.

Please try this workaround to confirm: In the account configuration dialog, in the "advanced" tab, enter "example.com" as "Send custom hostname to server".

Please open a new bug report for that.
Comment 31 kzi 2017-12-22 21:23:01 UTC
(In reply to Fabian Vogt from comment #30)
> ksmtp sends the server's hostname instead of the local hostname by accident
> with the "EHLO" command. The mail.snafu.de server rejects that immediately,
> but example.com works.
> 
> Please try this workaround to confirm: In the account configuration dialog,
> in the "advanced" tab, enter "example.com" as "Send custom hostname to
> server".

Indeed, that works around my issue. After your hint I learned:

> telnet mail.snafu.de 587
EHLO foo.bar
250-... (ok)
EHLO mail.snafu.de
550 EHLO/HELO not allowed by local policy.
Connection closed by foreign host.

So seemingly /every/ EHLO domain parameter but the server host is accepted!
Thank you so much for this offtopic help!

> Please open a new bug report for that.

I will, now that I have a clue. ;)
Comment 32 Fabian Vogt 2017-12-23 12:09:34 UTC
Git commit 5199ed07428a03f1aa340da3ae99fcfa62ba2751 by Fabian Vogt.
Committed on 23/12/2017 at 12:09.
Pushed by fvogt into branch 'Applications/17.12'.

Send the correct hostname with the HELO/EHLO command

Summary:
It sent the server's hostname previously, which some reject.

Test Plan: Ran nc as smtp server, uses the right hostname for EHLO now.

Reviewers: mlaurent, dvratil

Subscribers: #kde_pim

Tags: #kde_pim

Differential Revision: https://phabricator.kde.org/D9485

M  +13   -1    src/session.cpp

https://commits.kde.org/ksmtp/5199ed07428a03f1aa340da3ae99fcfa62ba2751
Comment 33 Fabian Vogt 2017-12-23 12:09:34 UTC
Git commit ec2afd27c790fbde63a9c2bdd1f97a59fe04b18e by Fabian Vogt.
Committed on 23/12/2017 at 12:09.
Pushed by fvogt into branch 'Applications/17.12'.

Fix duplicate authentication

Summary:
The response to EHLO triggers an authentication command, but with TLS
two EHLOs are sent: For the 220 from the server and after TLS negotiation.
However, sending it twice results in an unexpected "503 already authenticated"
response which ends up getting parsed by the SendJob, causing confusion.

By leaving the EHLO-resending to the SessionPrivate, the state can be properly
tracked.
Related: bug 388068

Reviewers: mlaurent, dvratil

Subscribers: lbeltrame, cgiboudeaux

Differential Revision: https://phabricator.kde.org/D9476

M  +19   -10   src/session.cpp
M  +1    -0    src/session_p.h
M  +0    -1    src/sessionthread.cpp

https://commits.kde.org/ksmtp/ec2afd27c790fbde63a9c2bdd1f97a59fe04b18e
Comment 34 Urs Joss 2017-12-23 14:41:25 UTC
Thanks Fabian. The patch (via archlinux ksmtp-17.12.0-2) solves the issue for me.
Comment 35 Olivier BELLEUX 2018-01-08 14:19:50 UTC
I just updated my opensuse to kde applications 17.12 and kmail refuses to send mail from any of my accounts.

Apparently Ksmtp is not ready yet.

Akonadi is already quite annoying, it was not worth adding.

Frankly Kde-Pim is the only part of the project that puts ko my tux; maybe it's time to go to Gnome?
Comment 36 Laurent Montel 2018-01-08 14:33:06 UTC
(In reply to Olivier BELLEUX from comment #35)
> I just updated my opensuse to kde applications 17.12 and kmail refuses to
> send mail from any of my accounts.
> 
> Apparently Ksmtp is not ready yet.
> 
> Akonadi is already quite annoying, it was not worth adding.
> 
> Frankly Kde-Pim is the only part of the project that puts ko my tux; maybe
> it's time to go to Gnome?

As wrote it's fixed in 17.12.1 so for sure 17.12.0 is broken...
Comment 37 Fabian Vogt 2018-01-08 14:40:04 UTC
(In reply to Olivier BELLEUX from comment #35)
> I just updated my opensuse to kde applications 17.12 and kmail refuses to
> send mail from any of my accounts.

ksmtp 17.12.0 in openSUSE contains the STARTTLS fix, but not the EHLO hostname
fix. It will be in the snapshot after the next snapshot.
So: Be patient, it's fixed.
If it isn't, please open a new bug report with some more information.

> Apparently Ksmtp is not ready yet.
> 
> Akonadi is already quite annoying, it was not worth adding.
>
> Frankly Kde-Pim is the only part of the project that puts ko my tux; maybe
> it's time to go to Gnome?

You can use KDE Applications + Desktop just fine without akonadi.
Or you can run KMail on GNOME, whatever you want.
Point is: This does not belong here.