File: smtp.rb

package info (click to toggle)
ruby-mail 2.7.1%2Bdfsg1-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 5,732 kB
  • sloc: ruby: 71,628; makefile: 3
file content (28 lines) | stat: -rw-r--r-- 709 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# encoding: utf-8
# frozen_string_literal: true

# This is a backport of r30294 from ruby trunk because of a bug in net/smtp.
# http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=30294
#
# Fixed in Ruby 1.9.3 - tlsconnect also does not exist in some early versions of ruby
if RUBY_VERSION < '1.9.3'
  module Net
    class SMTP
      begin
        alias_method :original_tlsconnect, :tlsconnect

        def tlsconnect(s)
          verified = false
          begin
            original_tlsconnect(s).tap { verified = true }
          ensure
            unless verified
              s.close rescue nil
            end
          end
        end
      rescue NameError
      end
    end
  end
end