Ruby smtp and gmail

[code]
     require 'net/smtp'
    Net::SMTP.start('smtp.gmail.com', 25,'rubytalk@gmail.com' ,
'password' , :login ) do |smtp|
      smtp.open_message_stream('rubytalk@gmail.com',
['rubytalk@gmail.com']) do |f|
        f.puts 'From:rubytalk@gmail.com'
        f.puts 'To:rubytalk@gmail.com'
        f.puts 'Subject: test message'
        f.puts
        f.puts 'This is a test message.'
      end
    end
[/code]

The error i get is
/usr/local/lib/ruby/1.8/net/smtp.rb:680:in `check_response': 530 5.7.0
Must issue a STARTTLS command first (Net::SMTPUnknownError)
        from /usr/local/lib/ruby/1.8/net/smtp.rb:593:in `auth_cram_md5'
        from /usr/local/lib/ruby/1.8/net/smtp.rb:592:in `critical'
        from /usr/local/lib/ruby/1.8/net/smtp.rb:592:in `auth_cram_md5'
        from /usr/local/lib/ruby/1.8/net/smtp.rb:571:in `__send__'
        from /usr/local/lib/ruby/1.8/net/smtp.rb:571:in `authenticate'
        from /usr/local/lib/ruby/1.8/net/smtp.rb:411:in `do_start'
        from /usr/local/lib/ruby/1.8/net/smtp.rb:378:in `start'
        from /usr/local/lib/ruby/1.8/net/smtp.rb:316:in `start'
        from email.rb:2

any one find a fix for this or a work around? Am i doing it wrong?
will it work with other smtp servers? I only have gmail to work with.
BEcker

Hi,

ruby talk wrote:

The error i get is
/usr/local/lib/ruby/1.8/net/smtp.rb:680:in `check_response': 530 5.7.0
Must issue a STARTTLS command first (Net::SMTPUnknownError)

That means that the server requires an encrypted connection via TLS, and the
SMTP module doesn't appear to support that (many less powerful clients don't).

Many other mail servers will accept your mails; only a select few actually
*require* TLS/SSL (mine is among them ;)).

You might want to try setting up an SSL tunnel that locally encrypts things
and sends them to the server's SMTPS port (465). This is probably easier to
do outside Ruby, though.

···

--
Best regards,
Jan 'jast' Krueger <usenet@zoidberg.org>, Aachen, Germany
(mails to <jast@...> go through less strict spam checking)

I'm betting it's Gmail's ssl requirement. More here...
http://www.google.com/search?q=gmail+use+secure+connection+ssl

···

On 5/12/05, ruby talk <rubytalk@gmail.com> wrote:

[code]
     require 'net/smtp'
    Net::SMTP.start('smtp.gmail.com', 25,'rubytalk@gmail.com' ,
'password' , :login ) do |smtp|
      smtp.open_message_stream('rubytalk@gmail.com',
['rubytalk@gmail.com']) do |f|
        f.puts 'From:rubytalk@gmail.com'
        f.puts 'To:rubytalk@gmail.com'
        f.puts 'Subject: test message'
        f.puts
        f.puts 'This is a test message.'
      end
    end
[/code]

The error i get is
/usr/local/lib/ruby/1.8/net/smtp.rb:680:in `check_response': 530 5.7.0
Must issue a STARTTLS command first (Net::SMTPUnknownError)
        from /usr/local/lib/ruby/1.8/net/smtp.rb:593:in `auth_cram_md5'
        from /usr/local/lib/ruby/1.8/net/smtp.rb:592:in `critical'
        from /usr/local/lib/ruby/1.8/net/smtp.rb:592:in `auth_cram_md5'
        from /usr/local/lib/ruby/1.8/net/smtp.rb:571:in `__send__'
        from /usr/local/lib/ruby/1.8/net/smtp.rb:571:in `authenticate'
        from /usr/local/lib/ruby/1.8/net/smtp.rb:411:in `do_start'
        from /usr/local/lib/ruby/1.8/net/smtp.rb:378:in `start'
        from /usr/local/lib/ruby/1.8/net/smtp.rb:316:in `start'
        from email.rb:2

any one find a fix for this or a work around? Am i doing it wrong?
will it work with other smtp servers? I only have gmail to work with.
BEcker

--
Bill Guindon (aka aGorilla)

[code]
     require 'net/smtp'
    Net::SMTP.start('smtp.gmail.com', 25,'rubytalk@gmail.com' ,
'password' , :login ) do |smtp|

                ^^^^^^
You might need to enter 'login' here.

I think Net::SMTP supports only 'login', 'plain' and, or 'cram_md5' methods for authentication, whereas 'cram_md5' is default and here in your attempt 'cram_md5' was selected 'cause :login was wrong. hence, 'tls' and, or 'starttls' is not available as yet.

I'm working on Net:NNTP, after reading concerned RFC's I shall implement 'starttls' and, or other requisite methods too. The list of documents is long [SSL-Talk List FAQ] Secure Sockets Layer Discussion List FAQ v1.1.1, so it may take time to implement all these functionalities.

      smtp.open_message_stream('rubytalk@gmail.com',
['rubytalk@gmail.com']) do |f|
        f.puts 'From:rubytalk@gmail.com'
        f.puts 'To:rubytalk@gmail.com'
        f.puts 'Subject: test message'
        f.puts
        f.puts 'This is a test message.'
      end
    end
[/code]

The error i get is
/usr/local/lib/ruby/1.8/net/smtp.rb:680:in `check_response': 530 5.7.0
Must issue a STARTTLS command first (Net::SMTPUnknownError)

The smtp.gmail.com supports only secure connections i.e TLS/SSL, that's why it is asking for a AUTH STARTTLS command.

        from /usr/local/lib/ruby/1.8/net/smtp.rb:593:in `auth_cram_md5'
        from /usr/local/lib/ruby/1.8/net/smtp.rb:592:in `critical'
        from /usr/local/lib/ruby/1.8/net/smtp.rb:592:in `auth_cram_md5'
        from /usr/local/lib/ruby/1.8/net/smtp.rb:571:in `__send__'
        from /usr/local/lib/ruby/1.8/net/smtp.rb:571:in `authenticate'
        from /usr/local/lib/ruby/1.8/net/smtp.rb:411:in `do_start'
        from /usr/local/lib/ruby/1.8/net/smtp.rb:378:in `start'
        from /usr/local/lib/ruby/1.8/net/smtp.rb:316:in `start'
        from email.rb:2

any one find a fix for this or a work around? Am i doing it wrong?
will it work with other smtp servers? I only have gmail to work with.
BEcker

I know, this information could only be of little use to you at this time and may not help you that much in resolving the isse at hend.

Regards,

···

On 05/13/2005 06:30 AM, ruby talk wrote:
--
Dr Balwinder Singh Dheeman Registered Linux User: #229709
CLLO (Chief Linux Learning Officer) Machines: #168573, 170593, 259192
Anu's Linux@HOME Distros: Ubuntu, Fedora, Knoppix
More: http://anu.homelinux.net/~bsd/ Visit: http://counter.li.org/

I actually hacked up something a while ago that allows me to connect to gmail.
Basically, I overrode the base socket to use SSL (or something like that). Let me
know if you want me to dig up the code.

-Shalev

···

On May 12, 2005, at 9:15 PM, Bill Guindon wrote:

On 5/12/05, ruby talk <rubytalk@gmail.com> wrote:

any one find a fix for this or a work around? Am i doing it wrong?
will it work with other smtp servers? I only have gmail to work with.
BEcker

I'm betting it's Gmail's ssl requirement. More here...
gmail use secure connection ssl - Google Search

--
Bill Guindon (aka aGorilla)

Hi,

  In mail "Re: ruby smtp and gmail"

···

Jan 'jast' Krueger <usenet@zoidberg.org> wrote:

> /usr/local/lib/ruby/1.8/net/smtp.rb:680:in `check_response': 530 5.7.0
> Must issue a STARTTLS command first (Net::SMTPUnknownError)

That means that the server requires an encrypted connection via TLS, and the
SMTP module doesn't appear to support that (many less powerful clients don't).

Many other mail servers will accept your mails; only a select few actually
*require* TLS/SSL (mine is among them ;)).

You might want to try setting up an SSL tunnel that locally encrypts things
and sends them to the server's SMTPS port (465). This is probably easier to
do outside Ruby, though.

net/smtp supports SMTPS in CVS HEAD.
It might work with Ruby 1.8.

Regards,
Minero Aoki

Hello,
Yes i would like to view your code.
Becker

···

On 5/13/05, Shalev NessAiver <shalev@simplyphysics.com> wrote:

On May 12, 2005, at 9:15 PM, Bill Guindon wrote:

> On 5/12/05, ruby talk <rubytalk@gmail.com> wrote:
>>
>> any one find a fix for this or a work around? Am i doing it wrong?
>> will it work with other smtp servers? I only have gmail to work with.
>> BEcker
>>
>
> I'm betting it's Gmail's ssl requirement. More here...
> gmail use secure connection ssl - Google Search
>
> --
> Bill Guindon (aka aGorilla)

I actually hacked up something a while ago that allows me to connect to
gmail.
Basically, I overrode the base socket to use SSL (or something like
that). Let me
know if you want me to dig up the code.

-Shalev