[Dovecot] NO: Unsupported authentication mechanism
I'm happily using dovecot as my IMAP server and accessing mails using Thunderbird... but I want to use the Net::IMAP facilities in the Ruby standard library to write some scripts to automate various spam-related tasks & housekeeping.
My Ruby script:
require "net/imap"
imap = Net::IMAP.new('localhost')
imap.authenticate('LOGIN','myuser','mypassword')
# More stuff using imap...
From the documentation LOGIN uses plaintext authentication - which I understand is always acceptable for Dovecot when connecting from localhost. On the 3rd line I get a "NO response" exception raised (indicating that the IMAP server replied "NO") and the error message "Net::IMAP::NoResponseError: Unsupported authentication mechanism" If I change 'LOGIN' to 'CRAM-MD5' (the other value supported by Net::IMAP) then I get a similar (but not identical) error: "Net::IMAP::NoResponseError: Authentication failed: Unsupported authentication mechanism" If I use anything other than either 'LOGIN' or 'CRAM-MD5' I get an error from the Net::IMAP library saying "Unknown auth type" - which is reasonable.
N.B. I've tried both where 'myuser' and 'mypassword' are valid - and not... this doesn't affect the error messages.
There doesn't seem to be anything of interest in /var/log/messages...
Can anyone tell me what is going wrong, and how to resolve this?
Steve [Dovecot] said the following on 2005-09-14 18:53:
I'm happily using dovecot as my IMAP server and accessing mails using Thunderbird... but I want to use the Net::IMAP facilities in the Ruby standard library to write some scripts to automate various spam-related tasks & housekeeping.
hi Steve,
you may find that perl Mail::Audit does the job for you at source -- as soon as email is delivered, your .forward can call Mail::Audit directly, and you can script the output. I've found this more flexible and easier than procmail's satanic syntax, and better than doing it after the mail is delivered.
My Ruby script:
require "net/imap" imap = Net::IMAP.new('localhost') imap.authenticate('LOGIN','myuser','mypassword') # More stuff using imap...
From the documentation LOGIN uses plaintext authentication - which I understand is always acceptable for Dovecot when connecting from localhost. On the 3rd line I get a "NO response" exception raised (indicating that the IMAP server replied "NO") and the error message "Net::IMAP::NoResponseError: Unsupported authentication mechanism" If I change 'LOGIN' to 'CRAM-MD5' (the other value supported by Net::IMAP) then I get a similar (but not identical) error: "Net::IMAP::NoResponseError: Authentication failed: Unsupported authentication mechanism" If I use anything other than either 'LOGIN' or 'CRAM-MD5' I get an error from the Net::IMAP library saying "Unknown auth type" - which is reasonable.
N.B. I've tried both where 'myuser' and 'mypassword' are valid - and not... this doesn't affect the error messages.
There doesn't seem to be anything of interest in /var/log/messages...
Can anyone tell me what is going wrong, and how to resolve this?
anyway, to your original issue, whats not working? this script works fine for my dovecot server, from localhost. Can you post your dovecot.conf, output of ifconfig -A (so we can see whether you have local or remote connections) and the results from setting
imap_listen = *
auth_verbose = yes
in dovecot.conf.
you may want to enable (& read)
#log_path = #info_log_path =
as well.
FWIW on my OpenBSD 3.7, I get info like this: Sep 14 20:03:11 scorch imap-login: Aborted login [10.0.0.50] in /var/maillog
I recommend to STFW & read these:
http://wiki.dovecot.org/moin.cgi/QuestionsAndAnswers#head-4bf6d2af17ff018327...
http://wiki.dovecot.org/moin.cgi/QuestionsAndAnswers#head-42ea38790508b748ca... for a few more suggestions.
use Net::IMAP::Simple;
# open a connection to the IMAP server
my $server = new Net::IMAP::Simple( 'imap.host' );
# login
$server->login( 'me', 'password' );
# the list of all folders
@folders = $server->mailboxes();
map { print "$_\n"; } @folders;
# close the connection
$server->quit();
cheers, scorch
-- out of the frying pan and into the fire
scorch wrote:
you may find that perl Mail::Audit does the job for you at source -- as soon as email is delivered, your .forward can call Mail::Audit directly, and you can script the output. I've found this more flexible and easier than procmail's satanic syntax, and better than doing it after the mail is delivered.
The reason for wanting to interact via IMAP is that I want to use the script to report emails which have been manually verified as spam... so any strategy at mail delivery time is not going to meet my requirements. I wanted to use Ruby and Net::IMAP for two reasons... (1) I've been looking for an excuse to write something in Ruby... and (2) Ruby's standard library Net::IMAP supports add_response_handler() - which looks as if it will allow me to neatly implement a process driven by other IMAP clients moving messages into a "special" IMAP folder without any need to do polling. I'm in the early stages of investigation...
Ruby script: : anyway, to your original issue, whats not working? this script works fine for my dovecot server, from localhost. Can you post your dovecot.conf, output of ifconfig -A (so we can see whether you have local or remote connections) and the results from setting
I'm not sure why you want ifconfig - anyway - here it is:
eth0 Link encap:Ethernet HWaddr 00:50:BA:A1:56:3F inet addr:10.0.1.1 Bcast:10.0.255.255 Mask:255.255.0.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:15093541 errors:0 dropped:0 overruns:0 frame:0 TX packets:12362960 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:3757158178 (3583.1 Mb) TX bytes:572907848 (546.3 Mb) Interrupt:3 Base address:0xdc00
lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:3478338 errors:0 dropped:0 overruns:0 frame:0 TX packets:3478338 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:1234264260 (1177.0 Mb) TX bytes:1234264260 (1177.0 Mb)
Here's my /etc/dovecot.conf (comment lines removed for brevity)
login = imap login_process_per_connection = no login_processes_count = 1 login_max_logging_users = 16 login = pop3 max_mail_processes = 16 default_mail_env = maildir:%h/.maildir auth = default auth_mechanisms = plain auth_userdb = passwd auth_passdb = pam auth_user = root
imap_listen = * auth_verbose = yes #log_path = #info_log_path =
I doubt that it is due to not-listening as I get a "NO" response back over IMAP (accoring to the Ruby Docs) - so I must have established a TCP connection to the dovecot IMAP server. I'll have a play with auth_verbose and the logging functions...
FWIW on my OpenBSD 3.7, I get info like this: Sep 14 20:03:11 scorch imap-login: Aborted login [10.0.0.50] in /var/maillog
All my imap messages seem to go into /var/log/messages (on Gentoo Linux)
- but the only failure messages I get are like this:
Sep 14 16:33:31 gifu imap-login: Login: sjh [127.0.0.1] Sep 14 16:46:09 gifu imap-login: Disconnected: Inactivity [127.0.0.1]
I recommend to STFW & read these:
http://wiki.dovecot.org/moin.cgi/QuestionsAndAnswers#head-4bf6d2af17ff018327...
http://wiki.dovecot.org/moin.cgi/QuestionsAndAnswers#head-42ea38790508b748ca...
Will do - any specific explanaitons as to what's wrong for me are still welcome :-)
On Wed, 2005-09-14 at 17:53 +0100, Steve [Dovecot] wrote:
"Net::IMAP::NoResponseError: Unsupported authentication mechanism"
If I change 'LOGIN' to 'CRAM-MD5' (the other value supported by Net::IMAP) then I get a similar (but not identical) error: "Net::IMAP::NoResponseError: Authentication failed: Unsupported authentication mechanism" If I use anything other than either 'LOGIN' or 'CRAM-MD5' I get an error from the Net::IMAP library saying "Unknown auth type" - which is reasonable.
PLAIN is the standard plaintext mechanism. If you want to use others, you'll have to add them to auth_mechanisms setting. Dovecot also accepts LOGIN if you just add it there.
Timo Sirainen wrote:
On Wed, 2005-09-14 at 17:53 +0100, Steve [Dovecot] wrote:
"Net::IMAP::NoResponseError: Unsupported authentication
mechanism" If I change 'LOGIN' to 'CRAM-MD5' (the other value supported by Net::IMAP) then I get a similar (but not identical) error: "Net::IMAP::NoResponseError: Authentication failed: Unsupported authentication mechanism" If I use anything other than either 'LOGIN' or 'CRAM-MD5' I get an error from the Net::IMAP library saying "Unknown auth type" - which is reasonable.
PLAIN is the standard plaintext mechanism. If you want to use others, you'll have to add them to auth_mechanisms setting. Dovecot also accepts LOGIN if you just add it there.
Ah, ha... I'd assumed that 'LOGIN' as the authentication method for Ruby's Net::IMAP was synonymous with 'PLAIN' authentication. I'm using dovecot 0.99.14-r1 under Gentoo and I note that auth.txt makes no mention of a 'LOGIN' authentication mechanism. If I abandon the authenticate() method in Ruby and use the login() method instead I get much further... though I have to admit that I am confused as to why there's a need for both - as well as why the default authenticate() seems to be incompatible with my default dovecot configuration... frustrating.
Steve
Steve [Dovecot] wrote:
Ah, ha... I'd assumed that 'LOGIN' as the authentication method for Ruby's Net::IMAP was synonymous with 'PLAIN' authentication. I'm using dovecot 0.99.14-r1 under Gentoo and I note that auth.txt makes no mention of a 'LOGIN' authentication mechanism.
PLAIN and LOGIN are two different ways to pass username and password in plaintext (well, base-64 encoded but not encrypted in any way). LOGIN was invented for the Cyrus mail server (and they don't even use it any longer), so it isn't surprising that it wasn't mentioned.
HTH
John
-- John Peacock Director of Information Research and Technology Rowman & Littlefield Publishing Group 4501 Forbes Boulevard Suite H Lanham, MD 20706 301-459-3366 x.5010 fax 301-429-5748
participants (4)
-
John Peacock
-
scorch
-
Steve [Dovecot]
-
Timo Sirainen