Getting Net::IMAP to work with PLAIN auth type

Hi there,

        I'm new to rails and I've been successful tinkering around 

but
am miffed by the process of trying to connect to my mail server to
receive
email for ActiveMailer parsing. I’m hosted on TextDrive and have read
the
following article on the RubyonRails wiki:
Peak Obsession.

I want to connect to my TextDrive hosted email account using Net::IMAP
but
the problem is that the authentication method is ‘PLAIN.’ I’ve been
searching to find a good example of how to connect to an IMAP mailbox
using
the PlainAuthenticator, but I haven’t come up with anything. Can anyone
provide a code example of how to connect to an IMAP mailbox using the
‘PLAIN’ authentication method?

Thanks,

-Alex

Use the ‘login’ method instead of ‘authenticate’.

On May 16, 2006, at 5:53 AM, Alex Ressi wrote:

Thanks,

-Alex


Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails

Dae San H.
[email protected]

On May 16, 2006, at 8:23 AM, Dae San H. wrote:

Use the ‘login’ method instead of ‘authenticate’.
This won’t work if the IMAP server doesn’t support LOGIN. Mine doesn’t.


Eric H. - [email protected] - http://blog.segment7.net
This implementation is HODEL-HASH-9600 compliant

http://trackmap.robotcoop.com

Eric,

So LOGIN and PLAIN authentication are two different things? Why
doesn’t PLAIN authentication work then? I thought it was some sort
of bug.

Which one regular GUI email clients use?

cheers,
daesan

PS: By the way, TxD does support LOGIN.

On May 17, 2006, at 3:16 AM, Eric H. wrote:


Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails

Dae San H.
[email protected]

On May 15, 2006, at 1:53 PM, Alex Ressi wrote:

I want to connect to my TextDrive hosted email account using
Net::IMAP but the problem is that the authentication method is
?PLAIN.? I?ve been searching to find a good example of how to
connect to an IMAP mailbox using the PlainAuthenticator, but I
haven?t come up with anything.
That’s because there isn’t one.
Can anyone provide a code example of how to connect to an IMAP
mailbox using the ?PLAIN? authentication method?

I wrote an implementation for IMAPCleanse, but haven’t yet submitted
a patch to ruby-core because it should only work on SSL sockets.

Here it is:

RFC 2595 PLAIN Authenticator for Net::IMAP. Only for use with SSL

(but not

enforced).

class Net::IMAP::PlainAuthenticator

From RFC 2595 Section 6. PLAIN SASL Authentication

The mechanism consists of a single message from the client to the

server. The client sends the authorization identity (identity to

login as), followed by a US-ASCII NUL character, followed by the

authentication identity (identity whose password will be used),

followed by a US-ASCII NUL character, followed by the clear-text

password. The client may leave the authorization identity

empty to

indicate that it is the same as the authentication identity.

def process(data)
return [@user, @user, @password].join(“\0”)
end

private

Creates a new PlainAuthenticator that will authenticate with

+user+ and

+password+.

def initialize(user, password)
@user = user
@password = password
end

end

if defined? OpenSSL then
Net::IMAP.add_authenticator ‘PLAIN’, Net::IMAP::PlainAuthenticator
end

PS: This is really a question for ruby-talk.


Eric H. - [email protected] - http://blog.segment7.net
This implementation is HODEL-HASH-9600 compliant

http://trackmap.robotcoop.com

On May 16, 2006, at 1:09 PM, Dae San H. wrote:

So LOGIN and PLAIN authentication are two different things?

LOGIN sends the user and password as separately.

PLAIN sends the user and password in one ASCII NUL separated line
(and allows you to say things like “use this users password and get
that user’s email”)

Why doesn’t PLAIN authentication work then? I thought it was some
sort of bug.

Net::IMAP doesn’t have an authenticator for PLAIN. Writing one
wasn’t hard.

Which one regular GUI email clients use?

Mail.app supports password (probably LOGIN and PLAIN), CRAM-MD5,
Kerberos 4/5 and NTLM. I use SSL + PLAIN.


Eric H. - [email protected] - http://blog.segment7.net
This implementation is HODEL-HASH-9600 compliant

http://trackmap.robotcoop.com

I’ve been using SSL + LOGIN since PLAIN didn’t seem to work. I
didn’t realize that the authenticator was not implemented. Thanks
Eric! I wouldn’t have figured that out by myself!

best,
daesan

On May 17, 2006, at 7:40 AM, Eric H. wrote:

Why doesn’t PLAIN authentication work then? I thought it was some

Eric H. - [email protected] - http://blog.segment7.net
This implementation is HODEL-HASH-9600 compliant

http://trackmap.robotcoop.com


Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails

Dae San H.
[email protected]