Bug 342875 - Cannot send mail using an authentication smtp server that supports AUTH LOGIN
Summary: Cannot send mail using an authentication smtp server that supports AUTH LOGIN
Status: RESOLVED FIXED
Alias: None
Product: trojita
Classification: Applications
Component: SMTP (show other bugs)
Version: unspecified
Platform: Ubuntu Linux
: NOR normal
Target Milestone: ---
Assignee: Trojita default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-01-15 15:01 UTC by Frank Harrell
Modified: 2015-08-13 16:38 UTC (History)
0 users

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 Frank Harrell 2015-01-15 15:01:36 UTC
I am trying to use smtpauth.vanderbilt.edu which uses port 587 tlsstart with ID and password.  No combinations of smtp options gets me anywhere.  I get this error message:
Sending of the message failed with the following error: 5.7.4
Unrecognized authentication type

Sending email works fine from the command line using the linux sendemail package and this command: sendemail -f fromaddress -t toaddress -u subject -m "message" -s smtpauth.vanderbilt.edu:587 -o tls=yes -xu myid -xp 'mypw'

so I know this should be workable.  As an aside, if trojita had a way to allow sendemail command line all would be well.


Reproducible: Always
Comment 1 Jan Kundrát 2015-01-15 15:16:32 UTC
Try Method: Network, Encryption: Use Encryption (STARTTLS), and check the "Authenticate" checkbox and provide username and password. Yup, it's confusing that people use the same name for multiple things.

If that doesn't work for some reason, please attach the debugging output which the SMTP client in Trojita by default stores to stdout/stderr.

> As an aside, if trojita had a way to allow sendemail command line all would be well.

Trojita laready supports this, go to Settings -> SMTP -> Method: Local sendmail-compatible, Sendmail Executable: (whatever command and options you need). The interface which it expects is the same as `sendmail -bm -oi`, you might need to adapt that.
Comment 2 Frank Harrell 2015-01-15 16:42:19 UTC
Thanks for the very quick response.  The settings you describe with STARTTLS and Authenticate are exactly what I've tried.  Here is the log output:

SMTP >>> STARTTLS 
SMTP <<< 220 2.0.0 SMTP server ready
 
SMTP ** startClientEncruption 
SMTP >>> "EHLO localhost
" 
SMTP <<< 250-smtpauth.vanderbilt.edu Hello [68.52.34.57]
 
SMTP <<< 250-SIZE 26214400
 
SMTP <<< 250-PIPELINING
 
SMTP <<< 250-DSN
 
SMTP <<< 250-ENHANCEDSTATUSCODES
 
SMTP <<< 250-AUTH GSSAPI NTLM LOGIN
 
SMTP <<< 250-8BITMIME
 
SMTP <<< 250-BINARYMIME
 
SMTP <<< 250 CHUNKING
 
SMTP >>> AUTH PLAIN 
SMTP <<< 504 5.7.4 Unrecognized authentication type
 
Our university has this note in its setup page:
Some clients may require a change from the default authentication method to "Normal Password"

Concerning running sendemail I saw the "Local sendmail-compatible" option but did not see a way to divert information given to sendmail to the various command line arguments of sendemail.

Thanks
Frank
Comment 3 Jan Kundrát 2015-01-15 18:12:47 UTC
> SMTP <<< 250-AUTH GSSAPI NTLM LOGIN

Ah, so the issue is that Trojita tries to send AUTH PLAIN while the server only allows the non-standard and deprecated LOGIN mechanism. Do you happen to know which SMTP server is that (blind guess -- Exchange)?

Either way, adding support for https://tools.ietf.org/html/draft-murchison-sasl-login-00 to Trojita makes sense, if only for interoperability with intentionally crippled MTAs. Would you like to provide a patch for that?

> did not see a way to divert information given to sendmail to the various command line arguments of sendemail.

Trojita adds `-f youraddress@example.org` and uses the rest of the options as-is. It expects a sendmail-compatible API for the rest, and that includes being able to determine recipients and subject from the mail content itself, and to read the entire mail form the script's stdin.
Comment 4 Frank Harrell 2015-01-15 23:04:02 UTC
Thanks for your note.  Yes unfortunately I'm stuck with Exchange.  I would provide a patch if I knew what I was doing.

I tried SMTP method Local sendmail-compatible and specified this Sendmail Executable:
sendemail -s smtpauth.vanderbilt.edu:587 -o tls=yes -xu myid -xp 'mypassword'

but get an error that the to-address "is not a recognized option".  Then I added -f at the end of the sendemail line and got "The argument after -f was not an email address".
Comment 5 Thomas Lübking 2015-01-16 00:03:07 UTC
"sendEmail" != "sendMail"

"sendEmail" is a bunch of perl scripts with ... "interesting" API to send mails via smtp.
"sendMail" is the powerful postfix thing that's used by mail providers all around the world ;-)

If you want a simple & tiny but sendMail compliant MTA, use "msmtp"
http://msmtp.sourceforge.net/
Comment 6 Frank Harrell 2015-01-16 13:54:55 UTC
I think it's hopeless for me to try to figure out how to configure sendmail.  I installed msmtp but could not get certificates to work.  It's a shame that trojita does not already work with Exchange smtp as all other email systems I've ever used do.

I could not find a "how to find, fetch, and use certificates with msmtp for dummies" web page.  Trying to bypass certificates with --tls-certcheck=off did not work with our server.
Comment 7 Thomas Lübking 2015-01-16 16:35:14 UTC
See https://wiki.archlinux.org/index.php/msmtp

You want this
tls            on
tls_trust_file /etc/ssl/certs/ca-certificates.crt

in your ~/.msmtprc

Also there's a help section for trouble with broken tls certificates:
https://wiki.archlinux.org/index.php/msmtp#Issues_with_TLS

----
AUTH=LOGIN is afaik not an actual standard.
Comment 8 Jan Kundrát 2015-01-16 17:36:34 UTC
Could you please try the (largely untested) patch at https://gerrit.vesnicky.cesnet.cz/r/335 ?
Comment 9 Frank Harrell 2015-01-16 19:42:50 UTC
Thomas - I realize AUTH=LOGIN is not a standard, but sendmail, sendemail, mstmp, etc. work with it.  Thanks for the links.  I think my problems is that I don't know how to find and put my institution's ssl certificates in /etc/ssl/...

Thanks Jan for the patch.  I know how to use makefiles etc. but am not versed in installing versions with patches.

Frank
Comment 10 Thomas Lübking 2015-01-16 20:57:12 UTC
The patch is supposed to move upstream anyway, but you can also clone it (gerrit has download/clone/cherry-pick and whatnot links in the upper right of the page)
Comment 11 Jan Kundrát 2015-01-19 18:19:12 UTC
Git commit 834f07d84b4fa53ea00b20003b1ec87fa021b661 by Jan Kundrát.
Committed on 16/01/2015 at 17:33.
Pushed by gerrit into branch 'master'.

Enable non-standard SMTP AUTH LOGIN

Turns out that the library supports this, even with some rudimentary
autodetection. The problem was that the autodetection is not available
with our queue-commands-at-once approach, and that the code in Trojita
which called this was deliberately setting AUTH PLAIN for
"compatibility", see commit c5693ba7b9fbd40e55230c37711e4cc0e3588696.

Anyway, this is a hack, but it works. Did I say that the SMTP client
should be replaced?
Change-Id: I0911ca6aa2ea98099f4b14ee103c3465e7223122

M  +1    -4    src/MSA/SMTP.cpp
M  +20   -7    src/qwwsmtpclient/qwwsmtpclient.cpp

http://commits.kde.org/trojita/834f07d84b4fa53ea00b20003b1ec87fa021b661
Comment 12 Frank Harrell 2015-08-07 13:24:05 UTC
Still trojita will not properly authenticate; I cannot send mail using smtp on our Exchange server.  trojia is the only email client I have ever used that does not allow sending email this way.  If it weren't for that I would be a big user of trojita.
Comment 13 Frank Harrell 2015-08-07 13:24:56 UTC
(In reply to Frank Harrell from comment #12)
> Still trojita will not properly authenticate; I cannot send mail using smtp
> on our Exchange server.  trojia is the only email client I have ever used
> that does not allow sending email this way.  If it weren't for that I would
> be a big user of trojita.

p.s.  I am using the latest trojita nightly build for Xubuntu 15.04
Comment 14 Thomas Lübking 2015-08-07 17:47:08 UTC
Can you please post the updated SMTP jabber?
(As we should no longer end up in "SMTP <<< 504 5.7.4 Unrecognized authentication type")
Comment 15 Frank Harrell 2015-08-07 18:26:20 UTC
Cartainly.  It's below.  It is still 5.7.4.  This version of trojita 0.5 nightly from http://download.opensuse.org/repositories/home:/jkt-gentoo:/trojita/xUbuntu_15.04/amd64/

SMTP ** connectToHost 
SMTP <<< 220 SMTP OK
 
SMTP >>> "EHLO localhost
" 
SMTP <<< 250-smtpauth.vanderbilt.edu Hello [160.129.74.241]
 
SMTP <<< 250-SIZE 26214400
 
SMTP <<< 250-PIPELINING
 
SMTP <<< 250-DSN
 
SMTP <<< 250-ENHANCEDSTATUSCODES
 
SMTP <<< 250-STARTTLS
 
SMTP <<< 250-AUTH GSSAPI NTLM
 
SMTP <<< 250-8BITMIME
 
SMTP <<< 250-BINARYMIME
 
SMTP <<< 250 CHUNKING
 
SMTP >>> STARTTLS 
SMTP <<< 220 2.0.0 SMTP server ready
 
SMTP ** startClientEncruption 
SMTP >>> "EHLO localhost
" 
SMTP <<< 250-smtpauth.vanderbilt.edu Hello [160.129.74.241]
 
SMTP <<< 250-SIZE 26214400
 
SMTP <<< 250-PIPELINING
 
SMTP <<< 250-DSN
 
SMTP <<< 250-ENHANCEDSTATUSCODES
 
SMTP <<< 250-AUTH GSSAPI NTLM LOGIN
 
SMTP <<< 250-8BITMIME
 
SMTP <<< 250-BINARYMIME
 
SMTP <<< 250 CHUNKING
 
SMTP >>> AUTH PLAIN 
SMTP <<< 504 5.7.4 Unrecognized authentication type
Comment 16 Thomas Lübking 2015-08-08 00:54:32 UTC
*lol* - "fun with flags"

The patch is trivial, but I think Jan is on vacation.
Can you compile it yourself?

------

diff --git a/src/qwwsmtpclient/qwwsmtpclient.h b/src/qwwsmtpclient/qwwsmtpclient.h
index d036e80..826b48b 100644
--- a/src/qwwsmtpclient/qwwsmtpclient.h
+++ b/src/qwwsmtpclient/qwwsmtpclient.h
@@ -56,7 +56,7 @@ public:
     enum State { Disconnected, Connecting, Connected, TLSRequested, Authenticating, Sending, Disconnecting };
     enum Option { NoOptions = 0, StartTlsOption, SizeOption, PipeliningOption, EightBitMimeOption, AuthOption };
     Q_DECLARE_FLAGS ( Options, Option );
-    enum AuthMode { AuthNone, AuthAny, AuthPlain, AuthLogin };
+    enum AuthMode { AuthNone = 0, AuthAny = 1, AuthPlain = 2, AuthLogin = 4 };
     Q_DECLARE_FLAGS ( AuthModes, AuthMode );
     void setLocalName(const QString &ln);
     void setLocalNameEncrypted(const QString &ln);
Comment 17 Frank Harrell 2015-08-08 03:20:04 UTC
I wasn't able to run cmake after the recommended git pull because of complexities of Qt dependencies so I doubt I'll be able to do this.  Thank you for working on it though, Thomas.
Comment 18 Thomas Lübking 2015-08-08 07:41:24 UTC
Ok, bad luck.

Patch is waiting here https://gerrit.vesnicky.cesnet.cz/r/#/c/489/ but check-trojita-qt4-gcc-release-el6 (continuous integration) is "queued".

I know there were lately issues with that build environment, but even if i had access to the CI system, I would not nearly know what to do there ;-)

=> You'll have to wait a week - or manage to build trojita yourself.

You'll require
- either the Qt5 or Qt4 *-dev packages
- cmake
- gcc
- *maybe* "extra-cmake-modules" (but I doubt so)
Comment 19 Frank Harrell 2015-08-08 13:29:07 UTC
I could do git clone and follow the instructions for compiling after doing sudo apt-get install cmake qt4-dev-tools (the trojita files seem to be set up for Qt4 not Qt5).  Before running cmake .. I got in the src directory and ran patch < diff where diff is a file containing your diffs above.  

Now sending mail works fine.  Thank you very much Thomas!  I very much look forward to this making its way into the debian/ubuntu packaged versions in a week.
Comment 20 Thomas Lübking 2015-08-13 16:33:13 UTC
Git commit f4009a60a7b16611a351e720f9cc0a81ab366894 by Thomas Lübking.
Committed on 08/08/2015 at 07:21.
Pushed by gerrit into branch 'master'.

QWWSMTP: QFlags still requires flagged enum values

Though it could be "AuthMode" simply started as
exclusive values.

However, so far "authMode |= AuthLogin" actually
set "authMode |= (AuthAny|AuthPlain)" thus
commit 834f07d84b4fa53ea00b20003b1ec87fa021b661
did not actually lead into using AuthLogin
Change-Id: I0cb3142f3a4aaa18a5c52f623688644e14d58a40

M  +1    -1    src/qwwsmtpclient/qwwsmtpclient.h

http://commits.kde.org/trojita/f4009a60a7b16611a351e720f9cc0a81ab366894
Comment 21 Jan Kundrát 2015-08-13 16:38:50 UTC
(In reply to Frank Harrell from comment #19)
> the trojita files seem to be set up for Qt4 not Qt5

Yes, Qt4 is still the default. Switching to a Qt5-based build is done via the -DWITH_QT5=ON flag (and a new build dir is needed; it is not possible to convert a pre-existing thing where cmake has been run already).