net-smtp 0.1.0 → 0.3.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 78828322ead199854db6be7e42250f1a185f13979020922e49c9865c499c7305
4
- data.tar.gz: 88387d583063d1ee6478621d4e2d622582f09a7b7a11f50e9bd067575da8ba35
3
+ metadata.gz: a873c949eb563b55b9ea2d29eaecdf2bad09006b7cc2aab14954971021619de1
4
+ data.tar.gz: c7ed69e3a3e56805953b5ff7ed8f31288eeb4bd113a13e559b38fca5fd85e1cf
5
5
  SHA512:
6
- metadata.gz: fc0c2ba9462420db511321f9206db5035ecc3778e9e4b526634c7a98ffbc089bae94f4056a4385582f2cfe734a15f9ce8724f355cdbfbeb0c299fa3331d2f9e0
7
- data.tar.gz: 86b82c9b891c41fea7829ea8c201835930cf3ba93966b51c636d56aeb54f9e132d530264b9b2b93a42364cfe5d841b287df4173a56b9541ca22f3c0f9bbb4b60
6
+ metadata.gz: 87fcd365f156b81c1124182b09973665607f201909e3bdd8463a007dadda060f6cde0069d4c8db9127233a61531b276b9a0b15e93b77f691a04baacd4c09c6cc
7
+ data.tar.gz: d8930794d97b2c1dbb8e507bc72b6a4e2f58da8f7e14a6546e87aed8082bbaf7be7c0cde7adeb6c80f66d57c6237edeaf5bc07fbbba6e63905e7c5dcf3777ba1
data/lib/net/smtp.rb CHANGED
@@ -31,6 +31,17 @@ module Net
31
31
  module SMTPError
32
32
  # This *class* is a module for backward compatibility.
33
33
  # In later release, this module becomes a class.
34
+
35
+ attr_reader :response
36
+
37
+ def initialize(response, message: nil)
38
+ @response = response
39
+ @message = message
40
+ end
41
+
42
+ def message
43
+ @message || response.message
44
+ end
34
45
  end
35
46
 
36
47
  # Represents an SMTP authentication error.
@@ -146,8 +157,8 @@ module Net
146
157
  # The SMTP server will judge whether it should send or reject
147
158
  # the SMTP session by inspecting the HELO domain.
148
159
  #
149
- # Net::SMTP.start('your.smtp.server', 25,
150
- # 'mail.from.domain') { |smtp| ... }
160
+ # Net::SMTP.start('your.smtp.server', 25
161
+ # helo: 'mail.from.domain') { |smtp| ... }
151
162
  #
152
163
  # === SMTP Authentication
153
164
  #
@@ -157,17 +168,18 @@ module Net
157
168
  # SMTP.start/SMTP#start.
158
169
  #
159
170
  # # PLAIN
160
- # Net::SMTP.start('your.smtp.server', 25, 'mail.from.domain',
161
- # 'Your Account', 'Your Password', :plain)
171
+ # Net::SMTP.start('your.smtp.server', 25
172
+ # user: 'Your Account', secret: 'Your Password', authtype: :plain)
162
173
  # # LOGIN
163
- # Net::SMTP.start('your.smtp.server', 25, 'mail.from.domain',
164
- # 'Your Account', 'Your Password', :login)
174
+ # Net::SMTP.start('your.smtp.server', 25
175
+ # user: 'Your Account', secret: 'Your Password', authtype: :login)
165
176
  #
166
177
  # # CRAM MD5
167
- # Net::SMTP.start('your.smtp.server', 25, 'mail.from.domain',
168
- # 'Your Account', 'Your Password', :cram_md5)
178
+ # Net::SMTP.start('your.smtp.server', 25
179
+ # user: 'Your Account', secret: 'Your Password', authtype: :cram_md5)
169
180
  #
170
181
  class SMTP < Protocol
182
+ VERSION = "0.3.0"
171
183
 
172
184
  Revision = %q$Revision$.split[1]
173
185
 
@@ -190,8 +202,10 @@ module Net
190
202
  alias default_ssl_port default_tls_port
191
203
  end
192
204
 
193
- def SMTP.default_ssl_context
194
- OpenSSL::SSL::SSLContext.new
205
+ def SMTP.default_ssl_context(ssl_context_params = nil)
206
+ context = OpenSSL::SSL::SSLContext.new
207
+ context.set_params(ssl_context_params ? ssl_context_params : {})
208
+ context
195
209
  end
196
210
 
197
211
  #
@@ -201,11 +215,23 @@ module Net
201
215
  # server. +port+ is the port to connect to; it defaults to
202
216
  # port 25.
203
217
  #
218
+ # If +tls+ is true, enable TLS. The default is false.
219
+ # If +starttls+ is :always, enable STARTTLS, if +:auto+, use STARTTLS when the server supports it,
220
+ # if false, disable STARTTLS.
221
+ #
222
+ # If +tls_verify+ is true, verify the server's certificate. The default is true.
223
+ # If the hostname in the server certificate is different from +address+,
224
+ # it can be specified with +tls_hostname+.
225
+ #
226
+ # Additional SSLContext params can be added to +ssl_context_params+ hash argument and are passed to
227
+ # +OpenSSL::SSL::SSLContext#set_params+
228
+ #
229
+ # +tls_verify: true+ is equivalent to +ssl_context_params: { verify_mode: OpenSSL::SSL::VERIFY_PEER }+.
204
230
  # This method does not open the TCP connection. You can use
205
231
  # SMTP.start instead of SMTP.new if you want to do everything
206
232
  # at once. Otherwise, follow SMTP.new with SMTP#start.
207
233
  #
208
- def initialize(address, port = nil)
234
+ def initialize(address, port = nil, tls: false, starttls: :auto, tls_verify: true, tls_hostname: nil, ssl_context_params: nil)
209
235
  @address = address
210
236
  @port = (port || SMTP.default_port)
211
237
  @esmtp = true
@@ -216,9 +242,13 @@ module Net
216
242
  @read_timeout = 60
217
243
  @error_occurred = false
218
244
  @debug_output = nil
219
- @tls = false
220
- @starttls = false
221
- @ssl_context = nil
245
+ @tls = tls
246
+ @starttls = starttls
247
+ @ssl_context_tls = nil
248
+ @ssl_context_starttls = nil
249
+ @tls_verify = tls_verify
250
+ @tls_hostname = tls_hostname
251
+ @ssl_context_params = ssl_context_params
222
252
  end
223
253
 
224
254
  # Provide human-readable stringification of class state.
@@ -293,11 +323,11 @@ module Net
293
323
  # Enables SMTP/TLS (SMTPS: SMTP over direct TLS connection) for
294
324
  # this object. Must be called before the connection is established
295
325
  # to have any effect. +context+ is a OpenSSL::SSL::SSLContext object.
296
- def enable_tls(context = SMTP.default_ssl_context)
297
- raise 'openssl library not installed' unless defined?(OpenSSL)
298
- raise ArgumentError, "SMTPS and STARTTLS is exclusive" if @starttls
326
+ def enable_tls(context = nil)
327
+ raise 'openssl library not installed' unless defined?(OpenSSL::VERSION)
328
+ raise ArgumentError, "SMTPS and STARTTLS is exclusive" if @starttls == :always
299
329
  @tls = true
300
- @ssl_context = context
330
+ @ssl_context_tls = context
301
331
  end
302
332
 
303
333
  alias enable_ssl enable_tls
@@ -306,7 +336,7 @@ module Net
306
336
  # connection is established to have any effect.
307
337
  def disable_tls
308
338
  @tls = false
309
- @ssl_context = nil
339
+ @ssl_context_tls = nil
310
340
  end
311
341
 
312
342
  alias disable_ssl disable_tls
@@ -330,27 +360,27 @@ module Net
330
360
 
331
361
  # Enables SMTP/TLS (STARTTLS) for this object.
332
362
  # +context+ is a OpenSSL::SSL::SSLContext object.
333
- def enable_starttls(context = SMTP.default_ssl_context)
334
- raise 'openssl library not installed' unless defined?(OpenSSL)
363
+ def enable_starttls(context = nil)
364
+ raise 'openssl library not installed' unless defined?(OpenSSL::VERSION)
335
365
  raise ArgumentError, "SMTPS and STARTTLS is exclusive" if @tls
336
366
  @starttls = :always
337
- @ssl_context = context
367
+ @ssl_context_starttls = context
338
368
  end
339
369
 
340
370
  # Enables SMTP/TLS (STARTTLS) for this object if server accepts.
341
371
  # +context+ is a OpenSSL::SSL::SSLContext object.
342
- def enable_starttls_auto(context = SMTP.default_ssl_context)
343
- raise 'openssl library not installed' unless defined?(OpenSSL)
372
+ def enable_starttls_auto(context = nil)
373
+ raise 'openssl library not installed' unless defined?(OpenSSL::VERSION)
344
374
  raise ArgumentError, "SMTPS and STARTTLS is exclusive" if @tls
345
375
  @starttls = :auto
346
- @ssl_context = context
376
+ @ssl_context_starttls = context
347
377
  end
348
378
 
349
379
  # Disables SMTP/TLS (STARTTLS) for this object. Must be called
350
380
  # before the connection is established to have any effect.
351
381
  def disable_starttls
352
382
  @starttls = false
353
- @ssl_context = nil
383
+ @ssl_context_starttls = nil
354
384
  end
355
385
 
356
386
  # The address of the SMTP server to connect to.
@@ -400,12 +430,16 @@ module Net
400
430
  # SMTP session control
401
431
  #
402
432
 
433
+ #
434
+ # :call-seq:
435
+ # start(address, port = nil, helo: 'localhost', user: nil, secret: nil, authtype: nil, tls: false, starttls: :auto, tls_verify: true, tls_hostname: nil, ssl_context_params: nil) { |smtp| ... }
436
+ # start(address, port = nil, helo = 'localhost', user = nil, secret = nil, authtype = nil) { |smtp| ... }
403
437
  #
404
438
  # Creates a new Net::SMTP object and connects to the server.
405
439
  #
406
440
  # This method is equivalent to:
407
441
  #
408
- # Net::SMTP.new(address, port).start(helo_domain, account, password, authtype)
442
+ # Net::SMTP.new(address, port).start(helo: helo_domain, user: account, secret: password, authtype: authtype, tls_verify: flag, tls_hostname: hostname, ssl_context_params: nil)
409
443
  #
410
444
  # === Example
411
445
  #
@@ -436,6 +470,19 @@ module Net
436
470
  # type, one of :plain, :login, or :cram_md5. See the discussion of
437
471
  # SMTP Authentication in the overview notes.
438
472
  #
473
+ # If +tls+ is true, enable TLS. The default is false.
474
+ # If +starttls+ is :always, enable STARTTLS, if +:auto+, use STARTTLS when the server supports it,
475
+ # if false, disable STARTTLS.
476
+ #
477
+ # If +tls_verify+ is true, verify the server's certificate. The default is true.
478
+ # If the hostname in the server certificate is different from +address+,
479
+ # it can be specified with +tls_hostname+.
480
+ #
481
+ # Additional SSLContext params can be added to +ssl_context_params+ hash argument and are passed to
482
+ # +OpenSSL::SSL::SSLContext#set_params+
483
+ #
484
+ # +tls_verify: true+ is equivalent to +ssl_context_params: { verify_mode: OpenSSL::SSL::VERIFY_PEER }+.
485
+ #
439
486
  # === Errors
440
487
  #
441
488
  # This method may raise:
@@ -449,10 +496,17 @@ module Net
449
496
  # * Net::ReadTimeout
450
497
  # * IOError
451
498
  #
452
- def SMTP.start(address, port = nil, helo = 'localhost',
453
- user = nil, secret = nil, authtype = nil,
454
- &block) # :yield: smtp
455
- new(address, port).start(helo, user, secret, authtype, &block)
499
+ def SMTP.start(address, port = nil, *args, helo: nil,
500
+ user: nil, secret: nil, password: nil, authtype: nil,
501
+ tls: false, starttls: :auto,
502
+ tls_verify: true, tls_hostname: nil, ssl_context_params: nil,
503
+ &block)
504
+ raise ArgumentError, "wrong number of arguments (given #{args.size + 2}, expected 1..6)" if args.size > 4
505
+ helo ||= args[0] || 'localhost'
506
+ user ||= args[1]
507
+ secret ||= password || args[2]
508
+ authtype ||= args[3]
509
+ new(address, port, tls: tls, starttls: starttls, tls_verify: tls_verify, tls_hostname: tls_hostname, ssl_context_params: ssl_context_params).start(helo: helo, user: user, secret: secret, authtype: authtype, &block)
456
510
  end
457
511
 
458
512
  # +true+ if the SMTP session has been started.
@@ -460,6 +514,10 @@ module Net
460
514
  @started
461
515
  end
462
516
 
517
+ #
518
+ # :call-seq:
519
+ # start(helo: 'localhost', user: nil, secret: nil, authtype: nil) { |smtp| ... }
520
+ # start(helo = 'localhost', user = nil, secret = nil, authtype = nil) { |smtp| ... }
463
521
  #
464
522
  # Opens a TCP connection and starts the SMTP session.
465
523
  #
@@ -487,7 +545,7 @@ module Net
487
545
  #
488
546
  # require 'net/smtp'
489
547
  # smtp = Net::SMTP.new('smtp.mail.server', 25)
490
- # smtp.start(helo_domain, account, password, authtype) do |smtp|
548
+ # smtp.start(helo: helo_domain, user: account, secret: password, authtype: authtype) do |smtp|
491
549
  # smtp.send_message msgstr, 'from@example.com', ['dest@example.com']
492
550
  # end
493
551
  #
@@ -511,8 +569,24 @@ module Net
511
569
  # * Net::ReadTimeout
512
570
  # * IOError
513
571
  #
514
- def start(helo = 'localhost',
515
- user = nil, secret = nil, authtype = nil) # :yield: smtp
572
+ def start(*args, helo: nil, user: nil, secret: nil, password: nil, authtype: nil)
573
+ raise ArgumentError, "wrong number of arguments (given #{args.size}, expected 0..4)" if args.size > 4
574
+ helo ||= args[0] || 'localhost'
575
+ user ||= args[1]
576
+ secret ||= password || args[2]
577
+ authtype ||= args[3]
578
+ if defined?(OpenSSL::VERSION)
579
+ ssl_context_params = @ssl_context_params || {}
580
+ unless ssl_context_params.has_key?(:verify_mode)
581
+ ssl_context_params[:verify_mode] = @tls_verify ? OpenSSL::SSL::VERIFY_PEER : OpenSSL::SSL::VERIFY_NONE
582
+ end
583
+ if @tls && @ssl_context_tls.nil?
584
+ @ssl_context_tls = SMTP.default_ssl_context(ssl_context_params)
585
+ end
586
+ if @starttls && @ssl_context_starttls.nil?
587
+ @ssl_context_starttls = SMTP.default_ssl_context(ssl_context_params)
588
+ end
589
+ end
516
590
  if block_given?
517
591
  begin
518
592
  do_start helo, user, secret, authtype
@@ -536,7 +610,12 @@ module Net
536
610
  private
537
611
 
538
612
  def tcp_socket(address, port)
539
- TCPSocket.open address, port
613
+ begin
614
+ Socket.tcp address, port, nil, nil, connect_timeout: @open_timeout
615
+ rescue Errno::ETIMEDOUT #raise Net:OpenTimeout instead for compatibility with previous versions
616
+ raise Net::OpenTimeout, "Timeout to open TCP connection to "\
617
+ "#{address}:#{port} (exceeds #{@open_timeout} seconds)"
618
+ end
540
619
  end
541
620
 
542
621
  def do_start(helo_domain, user, secret, authtype)
@@ -545,20 +624,17 @@ module Net
545
624
  check_auth_method(authtype || DEFAULT_AUTH_TYPE)
546
625
  check_auth_args user, secret
547
626
  end
548
- s = Timeout.timeout(@open_timeout, Net::OpenTimeout) do
549
- tcp_socket(@address, @port)
550
- end
627
+ s = tcp_socket(@address, @port)
551
628
  logging "Connection opened: #{@address}:#{@port}"
552
- @socket = new_internet_message_io(tls? ? tlsconnect(s) : s)
629
+ @socket = new_internet_message_io(tls? ? tlsconnect(s, @ssl_context_tls) : s)
553
630
  check_response critical { recv_response() }
554
631
  do_helo helo_domain
555
- if starttls_always? or (capable_starttls? and starttls_auto?)
632
+ if ! tls? and (starttls_always? or (capable_starttls? and starttls_auto?))
556
633
  unless capable_starttls?
557
- raise SMTPUnsupportedCommand,
558
- "STARTTLS is not supported on this server"
634
+ raise SMTPUnsupportedCommand.new(nil, message: "STARTTLS is not supported on this server")
559
635
  end
560
636
  starttls
561
- @socket = new_internet_message_io(tlsconnect(s))
637
+ @socket = new_internet_message_io(tlsconnect(s, @ssl_context_starttls))
562
638
  # helo response may be different after STARTTLS
563
639
  do_helo helo_domain
564
640
  end
@@ -576,15 +652,13 @@ module Net
576
652
  OpenSSL::SSL::SSLSocket.new socket, context
577
653
  end
578
654
 
579
- def tlsconnect(s)
655
+ def tlsconnect(s, context)
580
656
  verified = false
581
- s = ssl_socket(s, @ssl_context)
657
+ s = ssl_socket(s, context)
582
658
  logging "TLS connection started"
583
659
  s.sync_close = true
660
+ s.hostname = @tls_hostname || @address
584
661
  ssl_socket_connect(s, @open_timeout)
585
- if @ssl_context.verify_mode != OpenSSL::SSL::VERIFY_NONE
586
- s.post_connection_check(@address)
587
- end
588
662
  verified = true
589
663
  s
590
664
  ensure
@@ -725,7 +799,7 @@ module Net
725
799
  def authenticate(user, secret, authtype = DEFAULT_AUTH_TYPE)
726
800
  check_auth_method authtype
727
801
  check_auth_args user, secret
728
- send auth_method(authtype), user, secret
802
+ public_send auth_method(authtype), user, secret
729
803
  end
730
804
 
731
805
  def auth_plain(user, secret)
@@ -831,9 +905,6 @@ module Net
831
905
  end
832
906
 
833
907
  def mailfrom(from_addr)
834
- if $SAFE > 0
835
- raise SecurityError, 'tainted from_addr' if from_addr.tainted?
836
- end
837
908
  getok("MAIL FROM:<#{from_addr}>")
838
909
  end
839
910
 
@@ -859,9 +930,6 @@ module Net
859
930
  end
860
931
 
861
932
  def rcptto(to_addr)
862
- if $SAFE > 0
863
- raise SecurityError, 'tainted to_addr' if to_addr.tainted?
864
- end
865
933
  getok("RCPT TO:<#{to_addr}>")
866
934
  end
867
935
 
@@ -966,25 +1034,25 @@ module Net
966
1034
 
967
1035
  def check_response(res)
968
1036
  unless res.success?
969
- raise res.exception_class, res.message
1037
+ raise res.exception_class.new(res)
970
1038
  end
971
1039
  end
972
1040
 
973
1041
  def check_continue(res)
974
1042
  unless res.continue?
975
- raise SMTPUnknownError, "could not get 3xx (#{res.status}: #{res.string})"
1043
+ raise SMTPUnknownError.new(res, message: "could not get 3xx (#{res.status}: #{res.string})")
976
1044
  end
977
1045
  end
978
1046
 
979
1047
  def check_auth_response(res)
980
1048
  unless res.success?
981
- raise SMTPAuthenticationError, res.message
1049
+ raise SMTPAuthenticationError.new(res)
982
1050
  end
983
1051
  end
984
1052
 
985
1053
  def check_auth_continue(res)
986
1054
  unless res.continue?
987
- raise res.exception_class, res.message
1055
+ raise res.exception_class.new(res)
988
1056
  end
989
1057
  end
990
1058
 
@@ -1048,7 +1116,7 @@ module Net
1048
1116
  return {} unless @string[3, 1] == '-'
1049
1117
  h = {}
1050
1118
  @string.lines.drop(1).each do |line|
1051
- k, *v = line[4..-1].chomp.split
1119
+ k, *v = line[4..-1].split(' ')
1052
1120
  h[k] = v
1053
1121
  end
1054
1122
  h
data/net-smtp.gemspec CHANGED
@@ -1,25 +1,35 @@
1
- lib = File.expand_path("lib", __dir__)
2
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
- require "net/smtp/version"
1
+ # frozen_string_literal: true
2
+
3
+ name = File.basename(__FILE__, ".gemspec")
4
+ version = ["lib", Array.new(name.count("-"), "..").join("/")].find do |dir|
5
+ break File.foreach(File.join(__dir__, dir, "#{name.tr('-', '/')}.rb")) do |line|
6
+ /^\s*VERSION\s*=\s*"(.*)"/ =~ line and break $1
7
+ end rescue nil
8
+ end
4
9
 
5
10
  Gem::Specification.new do |spec|
6
- spec.name = "net-smtp"
7
- spec.version = Net::SMTP::VERSION
8
- spec.authors = ["Hiroshi SHIBATA"]
9
- spec.email = ["hsbt@ruby-lang.org"]
11
+ spec.name = name
12
+ spec.version = version
13
+ spec.authors = ["Yukihiro Matsumoto"]
14
+ spec.email = ["matz@ruby-lang.org"]
10
15
 
11
16
  spec.summary = %q{Simple Mail Transfer Protocol client library for Ruby.}
12
17
  spec.description = %q{Simple Mail Transfer Protocol client library for Ruby.}
13
18
  spec.homepage = "https://github.com/ruby/net-smtp"
14
- spec.license = "BSD-2-Clause"
19
+ spec.licenses = ["Ruby", "BSD-2-Clause"]
20
+ spec.required_ruby_version = ">= 2.5.0"
15
21
 
16
22
  spec.metadata["homepage_uri"] = spec.homepage
17
23
  spec.metadata["source_code_uri"] = spec.homepage
18
24
 
19
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
20
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
21
- end
22
- spec.bindir = "exe"
23
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
25
+ spec.files = %w[
26
+ LICENSE.txt
27
+ lib/net/smtp.rb
28
+ net-smtp.gemspec
29
+ ]
24
30
  spec.require_paths = ["lib"]
31
+
32
+ spec.add_dependency "net-protocol"
33
+ spec.add_dependency "digest"
34
+ spec.add_dependency "timeout"
25
35
  end
metadata CHANGED
@@ -1,40 +1,75 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: net-smtp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
- - Hiroshi SHIBATA
8
- autorequire:
9
- bindir: exe
7
+ - Yukihiro Matsumoto
8
+ autorequire:
9
+ bindir: bin
10
10
  cert_chain: []
11
- date: 2019-11-06 00:00:00.000000000 Z
12
- dependencies: []
11
+ date: 2021-10-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: net-protocol
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
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'
13
55
  description: Simple Mail Transfer Protocol client library for Ruby.
14
56
  email:
15
- - hsbt@ruby-lang.org
57
+ - matz@ruby-lang.org
16
58
  executables: []
17
59
  extensions: []
18
60
  extra_rdoc_files: []
19
61
  files:
20
- - ".gitignore"
21
- - ".travis.yml"
22
- - Gemfile
23
62
  - LICENSE.txt
24
- - README.md
25
- - Rakefile
26
- - bin/console
27
- - bin/setup
28
63
  - lib/net/smtp.rb
29
- - lib/net/smtp/version.rb
30
64
  - net-smtp.gemspec
31
65
  homepage: https://github.com/ruby/net-smtp
32
66
  licenses:
67
+ - Ruby
33
68
  - BSD-2-Clause
34
69
  metadata:
35
70
  homepage_uri: https://github.com/ruby/net-smtp
36
71
  source_code_uri: https://github.com/ruby/net-smtp
37
- post_install_message:
72
+ post_install_message:
38
73
  rdoc_options: []
39
74
  require_paths:
40
75
  - lib
@@ -42,15 +77,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
42
77
  requirements:
43
78
  - - ">="
44
79
  - !ruby/object:Gem::Version
45
- version: '0'
80
+ version: 2.5.0
46
81
  required_rubygems_version: !ruby/object:Gem::Requirement
47
82
  requirements:
48
83
  - - ">="
49
84
  - !ruby/object:Gem::Version
50
85
  version: '0'
51
86
  requirements: []
52
- rubygems_version: 3.0.3
53
- signing_key:
87
+ rubygems_version: 3.2.22
88
+ signing_key:
54
89
  specification_version: 4
55
90
  summary: Simple Mail Transfer Protocol client library for Ruby.
56
91
  test_files: []
data/.gitignore DELETED
@@ -1,9 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /_yardoc/
4
- /coverage/
5
- /doc/
6
- /pkg/
7
- /spec/reports/
8
- /tmp/
9
- Gemfile.lock
data/.travis.yml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- sudo: false
3
- language: ruby
4
- cache: bundler
5
- rvm:
6
- - 2.6.3
7
- before_install: gem install bundler -v 2.0.2
data/Gemfile DELETED
@@ -1,9 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- gemspec
4
-
5
- group :development do
6
- gem "bundler"
7
- gem "rake"
8
- gem "test-unit"
9
- end
data/README.md DELETED
@@ -1,97 +0,0 @@
1
- # Net::SMTP
2
-
3
- This library provides functionality to send internet mail via SMTP, the Simple Mail Transfer Protocol.
4
-
5
- For details of SMTP itself, see [RFC2821] (http://www.ietf.org/rfc/rfc2821.txt).
6
-
7
- ## Installation
8
-
9
- Add this line to your application's Gemfile:
10
-
11
- ```ruby
12
- gem 'net-smtp'
13
- ```
14
-
15
- And then execute:
16
-
17
- $ bundle
18
-
19
- Or install it yourself as:
20
-
21
- $ gem install net-smtp
22
-
23
- ## Usage
24
-
25
- ### Sending Messages
26
-
27
- You must open a connection to an SMTP server before sending messages.
28
- The first argument is the address of your SMTP server, and the second
29
- argument is the port number. Using SMTP.start with a block is the simplest
30
- way to do this. This way, the SMTP connection is closed automatically
31
- after the block is executed.
32
-
33
- ```ruby
34
- require 'net/smtp'
35
- Net::SMTP.start('your.smtp.server', 25) do |smtp|
36
- # Use the SMTP object smtp only in this block.
37
- end
38
- ```
39
-
40
- Replace 'your.smtp.server' with your SMTP server. Normally
41
- your system manager or internet provider supplies a server
42
- for you.
43
-
44
- Then you can send messages.
45
-
46
- ```ruby
47
- msgstr = <<END_OF_MESSAGE
48
- From: Your Name <your@mail.address>
49
- To: Destination Address <someone@example.com>
50
- Subject: test message
51
- Date: Sat, 23 Jun 2001 16:26:43 +0900
52
- Message-Id: <unique.message.id.string@example.com>
53
-
54
- This is a test message.
55
- END_OF_MESSAGE
56
-
57
- require 'net/smtp'
58
- Net::SMTP.start('your.smtp.server', 25) do |smtp|
59
- smtp.send_message msgstr,
60
- 'your@mail.address',
61
- 'his_address@example.com'
62
- end
63
- ```
64
-
65
- ### Closing the Session
66
-
67
- You MUST close the SMTP session after sending messages, by calling
68
- the #finish method:
69
-
70
- ```ruby
71
- # using SMTP#finish
72
- smtp = Net::SMTP.start('your.smtp.server', 25)
73
- smtp.send_message msgstr, 'from@address', 'to@address'
74
- smtp.finish
75
- ```
76
-
77
- You can also use the block form of SMTP.start/SMTP#start. This closes
78
- the SMTP session automatically:
79
-
80
- ```ruby
81
- # using block form of SMTP.start
82
- Net::SMTP.start('your.smtp.server', 25) do |smtp|
83
- smtp.send_message msgstr, 'from@address', 'to@address'
84
- end
85
- ```
86
-
87
- I strongly recommend this scheme. This form is simpler and more robust.
88
-
89
- ## Development
90
-
91
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
92
-
93
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
94
-
95
- ## Contributing
96
-
97
- Bug reports and pull requests are welcome on GitHub at https://github.com/hsbt/net-smtp.
data/Rakefile DELETED
@@ -1,10 +0,0 @@
1
- require "bundler/gem_tasks"
2
- require "rake/testtask"
3
-
4
- Rake::TestTask.new(:test) do |t|
5
- t.libs << "test"
6
- t.libs << "lib"
7
- t.test_files = FileList['test/**/test_*.rb']
8
- end
9
-
10
- task :default => [:test]
data/bin/console DELETED
@@ -1,7 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "bundler/setup"
4
- require "net/smtp"
5
-
6
- require "irb"
7
- IRB.start(__FILE__)
data/bin/setup DELETED
@@ -1,6 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
@@ -1,5 +0,0 @@
1
- module Net
2
- module SMTP
3
- VERSION = "0.1.0"
4
- end
5
- end