ruby smtp and gmail

R

ruby talk

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

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
 
J

Jan 'jast' Krueger

Hi,

ruby said:
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.
 
B

Bill Guindon

Code:
require 'net/smtp'
Net::SMTP.start('smtp.gmail.com', 25,'[email protected]' ,
'password' , :login ) do |smtp|
smtp.open_message_stream('[email protected]',
['[email protected]']) do |f|
f.puts 'From:[email protected]'
f.puts 'To:[email protected]'
f.puts 'Subject: test message'
f.puts
f.puts 'This is a test message.'
end
end
=20
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
=20
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
=20

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

--=20
Bill Guindon (aka aGorilla)
 
M

Minero Aoki

Hi,

In mail "Re: ruby smtp and gmail"
Jan 'jast' Krueger said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top