net-smtp 0.3.0 → 0.3.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/net/smtp.rb +58 -9
  3. data/net-smtp.gemspec +1 -1
  4. metadata +4 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a873c949eb563b55b9ea2d29eaecdf2bad09006b7cc2aab14954971021619de1
4
- data.tar.gz: c7ed69e3a3e56805953b5ff7ed8f31288eeb4bd113a13e559b38fca5fd85e1cf
3
+ metadata.gz: 6cec10bafc74434f6e530db0b2bcd3243184093ed5e1b845c7a79fadffa94820
4
+ data.tar.gz: 35368e13ce48265977d14a15eedde60e64f439c492b5817a3acbf3a8de60de51
5
5
  SHA512:
6
- metadata.gz: 87fcd365f156b81c1124182b09973665607f201909e3bdd8463a007dadda060f6cde0069d4c8db9127233a61531b276b9a0b15e93b77f691a04baacd4c09c6cc
7
- data.tar.gz: d8930794d97b2c1dbb8e507bc72b6a4e2f58da8f7e14a6546e87aed8082bbaf7be7c0cde7adeb6c80f66d57c6237edeaf5bc07fbbba6e63905e7c5dcf3777ba1
6
+ metadata.gz: 3b29f365b0770ccd868b14b65c05748651c6548f2d513ebbe196ed419b04d4d6c5ed14d0778758c8a53f137701986a638fce679f4b4fb48d39f7c64cf5bc408c
7
+ data.tar.gz: 6c8f1078d714e0ffc01f5de084f2087d79db1f781c1f5ada99c81371f7f069b16710f39abc20b1f70ef80351abcd3cd3bf7430c74e0416a0b7537b93819a45c6
data/lib/net/smtp.rb CHANGED
@@ -179,7 +179,7 @@ module Net
179
179
  # user: 'Your Account', secret: 'Your Password', authtype: :cram_md5)
180
180
  #
181
181
  class SMTP < Protocol
182
- VERSION = "0.3.0"
182
+ VERSION = "0.3.1.1"
183
183
 
184
184
  Revision = %q$Revision$.split[1]
185
185
 
@@ -251,6 +251,15 @@ module Net
251
251
  @ssl_context_params = ssl_context_params
252
252
  end
253
253
 
254
+ # If +true+, verify th server's certificate.
255
+ attr_accessor :tls_verify
256
+
257
+ # The hostname for verifying hostname in the server certificatate.
258
+ attr_accessor :tls_hostname
259
+
260
+ # Hash for additional SSLContext parameters.
261
+ attr_accessor :ssl_context_params
262
+
254
263
  # Provide human-readable stringification of class state.
255
264
  def inspect
256
265
  "#<#{self.class} #{@address}:#{@port} started=#{@started}>"
@@ -274,11 +283,14 @@ module Net
274
283
  capable?('STARTTLS')
275
284
  end
276
285
 
286
+ # true if the EHLO response contains +key+.
277
287
  def capable?(key)
278
288
  return nil unless @capabilities
279
289
  @capabilities[key] ? true : false
280
290
  end
281
- private :capable?
291
+
292
+ # The server capabilities by EHLO response
293
+ attr_reader :capabilities
282
294
 
283
295
  # true if server advertises AUTH PLAIN.
284
296
  # You cannot get valid value before opening SMTP session.
@@ -703,9 +715,9 @@ module Net
703
715
  # binary message with this method. +msgstr+ should include both
704
716
  # the message headers and body.
705
717
  #
706
- # +from_addr+ is a String representing the source mail address.
718
+ # +from_addr+ is a String or Net::SMTP::Address representing the source mail address.
707
719
  #
708
- # +to_addr+ is a String or Strings or Array of Strings, representing
720
+ # +to_addr+ is a String or Net::SMTP::Address or Array of them, representing
709
721
  # the destination mail address or addresses.
710
722
  #
711
723
  # === Example
@@ -716,6 +728,12 @@ module Net
716
728
  # ['dest@example.com', 'dest2@example.com']
717
729
  # end
718
730
  #
731
+ # Net::SMTP.start('smtp.example.com') do |smtp|
732
+ # smtp.send_message msgstr,
733
+ # Net::SMTP::Address.new('from@example.com', size: 12345),
734
+ # Net::SMTP::Address.new('dest@example.com', notify: :success)
735
+ # end
736
+ #
719
737
  # === Errors
720
738
  #
721
739
  # This method may raise:
@@ -752,9 +770,9 @@ module Net
752
770
  #
753
771
  # === Parameters
754
772
  #
755
- # +from_addr+ is a String representing the source mail address.
773
+ # +from_addr+ is a String or Net::SMTP::Address representing the source mail address.
756
774
  #
757
- # +to_addr+ is a String or Strings or Array of Strings, representing
775
+ # +to_addr+ is a String or Net::SMTP::Address or Array of them, representing
758
776
  # the destination mail address or addresses.
759
777
  #
760
778
  # === Example
@@ -904,8 +922,10 @@ module Net
904
922
  getok("EHLO #{domain}")
905
923
  end
906
924
 
925
+ # +from_addr+ is +String+ or +Net::SMTP::Address+
907
926
  def mailfrom(from_addr)
908
- getok("MAIL FROM:<#{from_addr}>")
927
+ addr = Address.new(from_addr)
928
+ getok((["MAIL FROM:<#{addr.address}>"] + addr.parameters).join(' '))
909
929
  end
910
930
 
911
931
  def rcptto_list(to_addrs)
@@ -916,7 +936,7 @@ module Net
916
936
  begin
917
937
  rcptto addr
918
938
  rescue SMTPAuthenticationError
919
- unknown_users << addr.dump
939
+ unknown_users << addr.to_s.dump
920
940
  else
921
941
  ok_users << addr
922
942
  end
@@ -929,8 +949,10 @@ module Net
929
949
  ret
930
950
  end
931
951
 
952
+ # +to_addr+ is +String+ or +Net::SMTP::Address+
932
953
  def rcptto(to_addr)
933
- getok("RCPT TO:<#{to_addr}>")
954
+ addr = Address.new(to_addr)
955
+ getok((["RCPT TO:<#{addr.address}>"] + addr.parameters).join(' '))
934
956
  end
935
957
 
936
958
  # This method sends a message.
@@ -1139,6 +1161,33 @@ module Net
1139
1161
  @debug_output << msg + "\n" if @debug_output
1140
1162
  end
1141
1163
 
1164
+ # Address with parametres for MAIL or RCPT command
1165
+ class Address
1166
+ # mail address [String]
1167
+ attr_reader :address
1168
+ # paramters [Array<String>]
1169
+ attr_reader :parameters
1170
+
1171
+ # :call-seq:
1172
+ # initialize(address, parameter, ...)
1173
+ #
1174
+ # address +String+ or +Net::SMTP::Address+
1175
+ # parameter +String+ or +Hash+
1176
+ def initialize(address, *args, **kw_args)
1177
+ if address.kind_of? Address
1178
+ @address = address.address
1179
+ @parameters = address.parameters
1180
+ else
1181
+ @address = address
1182
+ @parameters = (args + [kw_args]).map{|param| Array(param)}.flatten(1).map{|param| Array(param).compact.join('=')}
1183
+ end
1184
+ end
1185
+
1186
+ def to_s
1187
+ @address
1188
+ end
1189
+ end
1190
+
1142
1191
  end # class SMTP
1143
1192
 
1144
1193
  SMTPSession = SMTP # :nodoc:
data/net-smtp.gemspec CHANGED
@@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
17
17
  spec.description = %q{Simple Mail Transfer Protocol client library for Ruby.}
18
18
  spec.homepage = "https://github.com/ruby/net-smtp"
19
19
  spec.licenses = ["Ruby", "BSD-2-Clause"]
20
- spec.required_ruby_version = ">= 2.5.0"
20
+ spec.required_ruby_version = ">= 2.6.0"
21
21
 
22
22
  spec.metadata["homepage_uri"] = spec.homepage
23
23
  spec.metadata["source_code_uri"] = spec.homepage
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.0
4
+ version: 0.3.1.1
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-10-14 00:00:00.000000000 Z
11
+ date: 2024-01-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: net-protocol
@@ -77,14 +77,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
77
77
  requirements:
78
78
  - - ">="
79
79
  - !ruby/object:Gem::Version
80
- version: 2.5.0
80
+ version: 2.6.0
81
81
  required_rubygems_version: !ruby/object:Gem::Requirement
82
82
  requirements:
83
83
  - - ">="
84
84
  - !ruby/object:Gem::Version
85
85
  version: '0'
86
86
  requirements: []
87
- rubygems_version: 3.2.22
87
+ rubygems_version: 3.3.27
88
88
  signing_key:
89
89
  specification_version: 4
90
90
  summary: Simple Mail Transfer Protocol client library for Ruby.