From: "とみたまさひろ" Date: 2008-07-18T07:06:50+09:00 Subject: [ruby-dev:35572] Re: [Ruby 1.8 - Bug #221] Net::SMTPでSMTPのHELO/EHLOにデフォルトで不正なホスト名を使用 とみたです。 On Fri, 18 Jul 2008 02:30:21 +0900 Yukihiro Matsumoto wrote: > |1.8.6と1.8.7だけrevertしました。 > > ありがとうございます。 > > 1.8ですが、以下のどちらが望ましいと思いますか? > > * localhost。実質ダメな設定はありえないので。 > * 127.0.0.1。これってSMTP的にどうなんだろう? いっそのこと次のようにするのはどうでしょうか。 * SMTPサーバーに接続した時の自分のIPアドレスを逆引きしたホスト名 # 変えすぎ? Index: lib/net/smtp.rb =================================================================== --- lib/net/smtp.rb (リビジョン 18120) +++ lib/net/smtp.rb (作業コピー) @@ -437,7 +437,7 @@ # +port+ is the port to connect to; it defaults to port 25. # # +helo+ is the _HELO_ _domain_ provided by the client to the - # server (see overview comments); it defaults to 'localhost'. + # server (see overview comments); it defaults to the hostname of client. # # The remaining arguments are used for SMTP authentication, if required # or desired. +user+ is the account name; +secret+ is your password @@ -457,7 +457,7 @@ # * IOError # * TimeoutError # - def SMTP.start(address, port = nil, helo = 'localhost', + def SMTP.start(address, port = nil, helo = nil, user = nil, secret = nil, authtype = nil, &block) # :yield: smtp new(address, port).start(helo, user, secret, authtype, &block) @@ -518,7 +518,7 @@ # * IOError # * TimeoutError # - def start(helo = 'localhost', + def start(helo = nil, user = nil, secret = nil, authtype = nil) # :yield: smtp if block_given? begin @@ -552,6 +552,10 @@ logging "Connection opened: #{@address}:#{@port}" @socket = new_internet_message_io(tls? ? tlsconnect(s) : s) check_response critical { recv_response() } + unless helo_domain + addrinfo = s.addr + helo_domain = addrinfo[2] == addrinfo[3] ? "[#{addrinfo[3]}]" : addrinfo[2] + end do_helo helo_domain if starttls_always? or (capable_starttls? and starttls_auto?) unless capable_starttls? -- とみたまさひろ 3469 42CC 4D32 F53C AD98 65A5 8C37 FF09 69C1 6040