Project

General

Profile

Bug #9125

Net::SMTP - invalid method raised when attempting to connect using STARTTLS

Added by pveselov (Pawel Veselov) over 6 years ago. Updated over 6 years ago.

Status:
Closed
Priority:
Normal
Target version:
-
ruby -v:
ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-linux]
[ruby-core:58418]

Description

Simple attempt (in irb):

require 'net/smtp'
smtp = Net::SMTP.new('server', 587)
mtp.enable_starttls()
smtp.start()

NoMethodError: undefined method success?' for "200 dummy reply code":String
from /usr/local/rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/net/smtp.rb:949:in
check_response'
from /usr/local/rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/net/smtp.rb:554:in do_start'
from /usr/local/rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/net/smtp.rb:525:in
start'
from (irb):9
from /usr/local/rvm/rubies/ruby-2.0.0-p247/bin/irb:13:in `'

The problem is with the critical() method, the method returns the "dummy response" if there already was a pending error.
The fix is to replace the line of:

  return '200 dummy reply code' if @error_occured

to

  return Response.parse('200 dummy reply code') if @error_occured

Alternatively, one can have a "canned" dummy response instance, but that may be unnecessary considering this only happens in error path.

Updated by hsbt (Hiroshi SHIBATA) over 6 years ago

  • Assignee set to drbrain (Eric Hodel)

Could you review this?

#2

Updated by drbrain (Eric Hodel) over 6 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r43954.
Pawel, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


  • lib/net/smtp.rb (Net::SMTP#critical): Always return a Net::SMTP::Response. Patch by Pawel Veselov. [ruby-trunk - Bug #9125]
  • test/net/smtp/test_smtp.rb: Test for the above.

Updated by drbrain (Eric Hodel) over 6 years ago

  • Backport changed from 1.9.3: UNKNOWN, 2.0.0: UNKNOWN to 1.9.3: UNKNOWN, 2.0.0: REQUIRED

All other callers of #critical expect a Net::SMTP::Response so it seems Pawel's patch is correct.

Updated by nagachika (Tomoyuki Chikanaga) over 6 years ago

  • Backport changed from 1.9.3: UNKNOWN, 2.0.0: REQUIRED to 1.9.3: UNKNOWN, 2.0.0: DONE

r43954 was backported to ruby_2_0_0 at r44393.

Updated by usa (Usaku NAKAMURA) over 6 years ago

  • Backport changed from 1.9.3: UNKNOWN, 2.0.0: DONE to 1.9.3: DONE, 2.0.0: DONE

backported into ruby_1_9_3 at r44741.

Also available in: Atom PDF