Forum: Ruby on Rails Getting Net::IMAP to work with PLAIN auth type...

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Alex Ressi (Guest)
on 2006-05-16 00:55
(Received via mailing list)
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:
http://wiki.rubyonrails.com/rails/pages/HowToRecei....



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
Dae San H. (Guest)
on 2006-05-16 19:26
(Received via mailing list)
Use the 'login' method instead of 'authenticate'.

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

>
> Thanks,
>
> -Alex
>
>
>
> _______________________________________________
> Rails mailing list
> removed_email_address@domain.invalid
> http://lists.rubyonrails.org/mailman/listinfo/rails

Dae San H.
removed_email_address@domain.invalid
Eric H. (Guest)
on 2006-05-16 22:19
(Received via mailing list)
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. - removed_email_address@domain.invalid - http://blog.segment7.net
This implementation is HODEL-HASH-9600 compliant

http://trackmap.robotcoop.com
Eric H. (Guest)
on 2006-05-16 22:26
(Received via mailing list)
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. - removed_email_address@domain.invalid - http://blog.segment7.net
This implementation is HODEL-HASH-9600 compliant

http://trackmap.robotcoop.com
Dae San H. (Guest)
on 2006-05-17 00:10
(Received via mailing list)
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
> removed_email_address@domain.invalid
> http://lists.rubyonrails.org/mailman/listinfo/rails

Dae San H.
removed_email_address@domain.invalid
Eric H. (Guest)
on 2006-05-17 02:41
(Received via mailing list)
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. - removed_email_address@domain.invalid - http://blog.segment7.net
This implementation is HODEL-HASH-9600 compliant

http://trackmap.robotcoop.com
Dae San H. (Guest)
on 2006-05-17 08:44
(Received via mailing list)
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. - removed_email_address@domain.invalid - http://blog.segment7.net
> This implementation is HODEL-HASH-9600 compliant
>
> http://trackmap.robotcoop.com
>
>
> _______________________________________________
> Rails mailing list
> removed_email_address@domain.invalid
> http://lists.rubyonrails.org/mailman/listinfo/rails

Dae San H.
removed_email_address@domain.invalid
This topic is locked and can not be replied to.