net-smtp 0.3.1 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/net/smtp.rb +27 -10
  3. data/net-smtp.gemspec +0 -2
  4. metadata +3 -31
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fbf12984985ffef0271f09805060b2cfa5e72eb3955c8ce51ee8076b427e1a02
4
- data.tar.gz: 17c6420b495abe8b17446b1e667681b2680b02d894b3ce1e4ef6cffaa26ad1df
3
+ metadata.gz: 314f553cc9e988f56b964e62836e95e323974b6a66c26e2f02d1e6a7cc08e886
4
+ data.tar.gz: 43a203a0622f49e2fb32a6c8bc0f644cb703e3bc3bc1f25aa114434c1a9cc8e5
5
5
  SHA512:
6
- metadata.gz: 4d9372a9673256cc280600a1367a0c92bed91250209736b4b54c7219c115b1006e9fc66d465367729f53ef393b9a8077b33f11f7578365d9cb84051e44b86976
7
- data.tar.gz: 0f7da80c1d40216684ff0927637b14dfb5597638913a0aa3a8f2ca68a3fc89724926736c719715171b7bcab915a9504016f10356b2622bc6da9e5f51238f8e52
6
+ metadata.gz: 486381bf1eee2cbd7cb4f12ca0253ee5b06fc2b1a012b3786bda9b30456c338c5de40889e639275cfcf22a83064d7c468aa06c8e21438adb1d1ab2133a3933eb
7
+ data.tar.gz: 97659f9e6505ea3aa10db92d5a99dc39d01ca55468ca28934b77061ccedd7ce74d8652927304ddf7fe4a21622e3572cca3bb92f19bae3a1b004bc7909783b530
data/lib/net/smtp.rb CHANGED
@@ -18,11 +18,13 @@
18
18
  #
19
19
 
20
20
  require 'net/protocol'
21
- require 'digest/md5'
22
- require 'timeout'
23
21
  begin
24
22
  require 'openssl'
25
23
  rescue LoadError
24
+ begin
25
+ require 'digest/md5'
26
+ rescue LoadError
27
+ end
26
28
  end
27
29
 
28
30
  module Net
@@ -35,8 +37,13 @@ module Net
35
37
  attr_reader :response
36
38
 
37
39
  def initialize(response, message: nil)
38
- @response = response
39
- @message = message
40
+ if response.is_a?(::Net::SMTP::Response)
41
+ @response = response
42
+ @message = message
43
+ else
44
+ @response = nil
45
+ @message = message || response
46
+ end
40
47
  end
41
48
 
42
49
  def message
@@ -179,7 +186,7 @@ module Net
179
186
  # user: 'Your Account', secret: 'Your Password', authtype: :cram_md5)
180
187
  #
181
188
  class SMTP < Protocol
182
- VERSION = "0.3.1"
189
+ VERSION = "0.3.3"
183
190
 
184
191
  Revision = %q$Revision$.split[1]
185
192
 
@@ -621,6 +628,16 @@ module Net
621
628
 
622
629
  private
623
630
 
631
+ def digest_class
632
+ @digest_class ||= if defined?(OpenSSL::Digest)
633
+ OpenSSL::Digest
634
+ elsif defined?(::Digest)
635
+ ::Digest
636
+ else
637
+ raise '"openssl" or "digest" library is required'
638
+ end
639
+ end
640
+
624
641
  def tcp_socket(address, port)
625
642
  begin
626
643
  Socket.tcp address, port, nil, nil, connect_timeout: @open_timeout
@@ -643,7 +660,7 @@ module Net
643
660
  do_helo helo_domain
644
661
  if ! tls? and (starttls_always? or (capable_starttls? and starttls_auto?))
645
662
  unless capable_starttls?
646
- raise SMTPUnsupportedCommand.new(nil, message: "STARTTLS is not supported on this server")
663
+ raise SMTPUnsupportedCommand, "STARTTLS is not supported on this server"
647
664
  end
648
665
  starttls
649
666
  @socket = new_internet_message_io(tlsconnect(s, @ssl_context_starttls))
@@ -883,14 +900,14 @@ module Net
883
900
 
884
901
  # CRAM-MD5: [RFC2195]
885
902
  def cram_md5_response(secret, challenge)
886
- tmp = Digest::MD5.digest(cram_secret(secret, IMASK) + challenge)
887
- Digest::MD5.hexdigest(cram_secret(secret, OMASK) + tmp)
903
+ tmp = digest_class::MD5.digest(cram_secret(secret, IMASK) + challenge)
904
+ digest_class::MD5.hexdigest(cram_secret(secret, OMASK) + tmp)
888
905
  end
889
906
 
890
907
  CRAM_BUFSIZE = 64
891
908
 
892
909
  def cram_secret(secret, mask)
893
- secret = Digest::MD5.digest(secret) if secret.size > CRAM_BUFSIZE
910
+ secret = digest_class::MD5.digest(secret) if secret.size > CRAM_BUFSIZE
894
911
  buf = secret.ljust(CRAM_BUFSIZE, "\0")
895
912
  0.upto(buf.size - 1) do |i|
896
913
  buf[i] = (buf[i].ord ^ mask).chr
@@ -1165,7 +1182,7 @@ module Net
1165
1182
  class Address
1166
1183
  # mail address [String]
1167
1184
  attr_reader :address
1168
- # paramters [Array<String>]
1185
+ # parameters [Array<String>]
1169
1186
  attr_reader :parameters
1170
1187
 
1171
1188
  # :call-seq:
data/net-smtp.gemspec CHANGED
@@ -30,6 +30,4 @@ Gem::Specification.new do |spec|
30
30
  spec.require_paths = ["lib"]
31
31
 
32
32
  spec.add_dependency "net-protocol"
33
- spec.add_dependency "digest"
34
- spec.add_dependency "timeout"
35
33
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: net-smtp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yukihiro Matsumoto
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-12-12 00:00:00.000000000 Z
11
+ date: 2022-10-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: net-protocol
@@ -24,34 +24,6 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
- - !ruby/object:Gem::Dependency
28
- name: digest
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
- - !ruby/object:Gem::Dependency
42
- name: timeout
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :runtime
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
27
  description: Simple Mail Transfer Protocol client library for Ruby.
56
28
  email:
57
29
  - matz@ruby-lang.org
@@ -84,7 +56,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
84
56
  - !ruby/object:Gem::Version
85
57
  version: '0'
86
58
  requirements: []
87
- rubygems_version: 3.3.0.dev
59
+ rubygems_version: 3.4.0.dev
88
60
  signing_key:
89
61
  specification_version: 4
90
62
  summary: Simple Mail Transfer Protocol client library for Ruby.