[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

ruby smtp and gmail

RubyTalk@gmail.com

5/13/2005 1:01:00 AM

[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


6 Answers

Jan 'jast' Krueger

5/13/2005 1:14:00 AM

0

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)

Bill Guindon

5/13/2005 1:16:00 AM

0

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
>

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

--
Bill Guindon (aka aGorilla)


Shalev NessAiver

5/13/2005 6:12:00 PM

0

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...
> http://www.google.com/search?q=gmail+use+secure+conn...
>
> --
> 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



Minero Aoki

5/14/2005 4:04:00 AM

0

Balwinder S Dheeman

5/14/2005 9:27:00 AM

0

On 05/13/2005 06:30 AM, ruby talk wrote:
> [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 http://www.faqs.org/faqs/computer-security/ssl-talk-faq/...,
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,
--
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... Visit: http://count...

RubyTalk@gmail.com

5/17/2005 1:01:00 PM

0

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...
> > http://www.google.com/search?q=gmail+use+secure+conn...
> >
> > --
> > 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
>
>