net-smtp 0.2.1 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 238243a17f2718efcc1c1ca44ac307df60c676d29f719298a599a2ff74e7b321
4
- data.tar.gz: 7e7e7c04e9a4f570512c30102376b7b53aef1e51f7b4a987ef9c56655e51ab62
3
+ metadata.gz: fbf12984985ffef0271f09805060b2cfa5e72eb3955c8ce51ee8076b427e1a02
4
+ data.tar.gz: 17c6420b495abe8b17446b1e667681b2680b02d894b3ce1e4ef6cffaa26ad1df
5
5
  SHA512:
6
- metadata.gz: f2ee31d1382efcc8757ac8ccea1003060a391d0f809f3e9ce4abcbb3374d7e125344d774875712a32b046ccde0bb5dc7a4c6aafd6aa80da3dc33230a7d3449f8
7
- data.tar.gz: 19a97301c3d8bb9ad4a0962cb862711d5f1693773b56bbccb4bf25e219aae7899bc174c9b2117747df82fdf88031cce06132b6398215dd645139535b83c57e7d
6
+ metadata.gz: 4d9372a9673256cc280600a1367a0c92bed91250209736b4b54c7219c115b1006e9fc66d465367729f53ef393b9a8077b33f11f7578365d9cb84051e44b86976
7
+ data.tar.gz: 0f7da80c1d40216684ff0927637b14dfb5597638913a0aa3a8f2ca68a3fc89724926736c719715171b7bcab915a9504016f10356b2622bc6da9e5f51238f8e52
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.
@@ -168,7 +179,7 @@ module Net
168
179
  # user: 'Your Account', secret: 'Your Password', authtype: :cram_md5)
169
180
  #
170
181
  class SMTP < Protocol
171
- VERSION = "0.2.1"
182
+ VERSION = "0.3.1"
172
183
 
173
184
  Revision = %q$Revision$.split[1]
174
185
 
@@ -191,12 +202,9 @@ module Net
191
202
  alias default_ssl_port default_tls_port
192
203
  end
193
204
 
194
- def SMTP.default_ssl_context(verify_peer=true)
205
+ def SMTP.default_ssl_context(ssl_context_params = nil)
195
206
  context = OpenSSL::SSL::SSLContext.new
196
- context.verify_mode = verify_peer ? OpenSSL::SSL::VERIFY_PEER : OpenSSL::SSL::VERIFY_NONE
197
- store = OpenSSL::X509::Store.new
198
- store.set_default_paths
199
- context.cert_store = store
207
+ context.set_params(ssl_context_params ? ssl_context_params : {})
200
208
  context
201
209
  end
202
210
 
@@ -207,11 +215,23 @@ module Net
207
215
  # server. +port+ is the port to connect to; it defaults to
208
216
  # port 25.
209
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 }+.
210
230
  # This method does not open the TCP connection. You can use
211
231
  # SMTP.start instead of SMTP.new if you want to do everything
212
232
  # at once. Otherwise, follow SMTP.new with SMTP#start.
213
233
  #
214
- 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)
215
235
  @address = address
216
236
  @port = (port || SMTP.default_port)
217
237
  @esmtp = true
@@ -222,12 +242,24 @@ module Net
222
242
  @read_timeout = 60
223
243
  @error_occurred = false
224
244
  @debug_output = nil
225
- @tls = false
226
- @starttls = :auto
245
+ @tls = tls
246
+ @starttls = starttls
227
247
  @ssl_context_tls = nil
228
248
  @ssl_context_starttls = nil
249
+ @tls_verify = tls_verify
250
+ @tls_hostname = tls_hostname
251
+ @ssl_context_params = ssl_context_params
229
252
  end
230
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
+
231
263
  # Provide human-readable stringification of class state.
232
264
  def inspect
233
265
  "#<#{self.class} #{@address}:#{@port} started=#{@started}>"
@@ -251,11 +283,14 @@ module Net
251
283
  capable?('STARTTLS')
252
284
  end
253
285
 
286
+ # true if the EHLO response contains +key+.
254
287
  def capable?(key)
255
288
  return nil unless @capabilities
256
289
  @capabilities[key] ? true : false
257
290
  end
258
- private :capable?
291
+
292
+ # The server capabilities by EHLO response
293
+ attr_reader :capabilities
259
294
 
260
295
  # true if server advertises AUTH PLAIN.
261
296
  # You cannot get valid value before opening SMTP session.
@@ -301,7 +336,7 @@ module Net
301
336
  # this object. Must be called before the connection is established
302
337
  # to have any effect. +context+ is a OpenSSL::SSL::SSLContext object.
303
338
  def enable_tls(context = nil)
304
- raise 'openssl library not installed' unless defined?(OpenSSL)
339
+ raise 'openssl library not installed' unless defined?(OpenSSL::VERSION)
305
340
  raise ArgumentError, "SMTPS and STARTTLS is exclusive" if @starttls == :always
306
341
  @tls = true
307
342
  @ssl_context_tls = context
@@ -338,7 +373,7 @@ module Net
338
373
  # Enables SMTP/TLS (STARTTLS) for this object.
339
374
  # +context+ is a OpenSSL::SSL::SSLContext object.
340
375
  def enable_starttls(context = nil)
341
- raise 'openssl library not installed' unless defined?(OpenSSL)
376
+ raise 'openssl library not installed' unless defined?(OpenSSL::VERSION)
342
377
  raise ArgumentError, "SMTPS and STARTTLS is exclusive" if @tls
343
378
  @starttls = :always
344
379
  @ssl_context_starttls = context
@@ -347,7 +382,7 @@ module Net
347
382
  # Enables SMTP/TLS (STARTTLS) for this object if server accepts.
348
383
  # +context+ is a OpenSSL::SSL::SSLContext object.
349
384
  def enable_starttls_auto(context = nil)
350
- raise 'openssl library not installed' unless defined?(OpenSSL)
385
+ raise 'openssl library not installed' unless defined?(OpenSSL::VERSION)
351
386
  raise ArgumentError, "SMTPS and STARTTLS is exclusive" if @tls
352
387
  @starttls = :auto
353
388
  @ssl_context_starttls = context
@@ -409,14 +444,14 @@ module Net
409
444
 
410
445
  #
411
446
  # :call-seq:
412
- # start(address, port = nil, helo: 'localhost', user: nil, secret: nil, authtype: nil, tls_verify: true, tls_hostname: nil) { |smtp| ... }
447
+ # 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| ... }
413
448
  # start(address, port = nil, helo = 'localhost', user = nil, secret = nil, authtype = nil) { |smtp| ... }
414
449
  #
415
450
  # Creates a new Net::SMTP object and connects to the server.
416
451
  #
417
452
  # This method is equivalent to:
418
453
  #
419
- # Net::SMTP.new(address, port).start(helo: helo_domain, user: account, secret: password, authtype: authtype, tls_verify: flag, tls_hostname: hostname)
454
+ # 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)
420
455
  #
421
456
  # === Example
422
457
  #
@@ -446,10 +481,20 @@ module Net
446
481
  # or other authentication token; and +authtype+ is the authentication
447
482
  # type, one of :plain, :login, or :cram_md5. See the discussion of
448
483
  # SMTP Authentication in the overview notes.
484
+ #
485
+ # If +tls+ is true, enable TLS. The default is false.
486
+ # If +starttls+ is :always, enable STARTTLS, if +:auto+, use STARTTLS when the server supports it,
487
+ # if false, disable STARTTLS.
488
+ #
449
489
  # If +tls_verify+ is true, verify the server's certificate. The default is true.
450
490
  # If the hostname in the server certificate is different from +address+,
451
491
  # it can be specified with +tls_hostname+.
452
492
  #
493
+ # Additional SSLContext params can be added to +ssl_context_params+ hash argument and are passed to
494
+ # +OpenSSL::SSL::SSLContext#set_params+
495
+ #
496
+ # +tls_verify: true+ is equivalent to +ssl_context_params: { verify_mode: OpenSSL::SSL::VERIFY_PEER }+.
497
+ #
453
498
  # === Errors
454
499
  #
455
500
  # This method may raise:
@@ -465,14 +510,15 @@ module Net
465
510
  #
466
511
  def SMTP.start(address, port = nil, *args, helo: nil,
467
512
  user: nil, secret: nil, password: nil, authtype: nil,
468
- tls_verify: true, tls_hostname: nil,
513
+ tls: false, starttls: :auto,
514
+ tls_verify: true, tls_hostname: nil, ssl_context_params: nil,
469
515
  &block)
470
516
  raise ArgumentError, "wrong number of arguments (given #{args.size + 2}, expected 1..6)" if args.size > 4
471
517
  helo ||= args[0] || 'localhost'
472
518
  user ||= args[1]
473
519
  secret ||= password || args[2]
474
520
  authtype ||= args[3]
475
- new(address, port).start(helo: helo, user: user, secret: secret, authtype: authtype, tls_verify: tls_verify, tls_hostname: tls_hostname, &block)
521
+ 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)
476
522
  end
477
523
 
478
524
  # +true+ if the SMTP session has been started.
@@ -482,7 +528,7 @@ module Net
482
528
 
483
529
  #
484
530
  # :call-seq:
485
- # start(helo: 'localhost', user: nil, secret: nil, authtype: nil, tls_verify: true, tls_hostname: nil) { |smtp| ... }
531
+ # start(helo: 'localhost', user: nil, secret: nil, authtype: nil) { |smtp| ... }
486
532
  # start(helo = 'localhost', user = nil, secret = nil, authtype = nil) { |smtp| ... }
487
533
  #
488
534
  # Opens a TCP connection and starts the SMTP session.
@@ -497,9 +543,6 @@ module Net
497
543
  # the type of authentication to attempt; it must be one of
498
544
  # :login, :plain, and :cram_md5. See the notes on SMTP Authentication
499
545
  # in the overview.
500
- # If +tls_verify+ is true, verify the server's certificate. The default is true.
501
- # If the hostname in the server certificate is different from +address+,
502
- # it can be specified with +tls_hostname+.
503
546
  #
504
547
  # === Block Usage
505
548
  #
@@ -538,20 +581,24 @@ module Net
538
581
  # * Net::ReadTimeout
539
582
  # * IOError
540
583
  #
541
- def start(*args, helo: nil,
542
- user: nil, secret: nil, password: nil, authtype: nil, tls_verify: true, tls_hostname: nil)
584
+ def start(*args, helo: nil, user: nil, secret: nil, password: nil, authtype: nil)
543
585
  raise ArgumentError, "wrong number of arguments (given #{args.size}, expected 0..4)" if args.size > 4
544
586
  helo ||= args[0] || 'localhost'
545
587
  user ||= args[1]
546
588
  secret ||= password || args[2]
547
589
  authtype ||= args[3]
548
- if @tls && @ssl_context_tls.nil?
549
- @ssl_context_tls = SMTP.default_ssl_context(tls_verify)
550
- end
551
- if @starttls && @ssl_context_starttls.nil?
552
- @ssl_context_starttls = SMTP.default_ssl_context(tls_verify)
590
+ if defined?(OpenSSL::VERSION)
591
+ ssl_context_params = @ssl_context_params || {}
592
+ unless ssl_context_params.has_key?(:verify_mode)
593
+ ssl_context_params[:verify_mode] = @tls_verify ? OpenSSL::SSL::VERIFY_PEER : OpenSSL::SSL::VERIFY_NONE
594
+ end
595
+ if @tls && @ssl_context_tls.nil?
596
+ @ssl_context_tls = SMTP.default_ssl_context(ssl_context_params)
597
+ end
598
+ if @starttls && @ssl_context_starttls.nil?
599
+ @ssl_context_starttls = SMTP.default_ssl_context(ssl_context_params)
600
+ end
553
601
  end
554
- @tls_hostname = tls_hostname
555
602
  if block_given?
556
603
  begin
557
604
  do_start helo, user, secret, authtype
@@ -575,7 +622,12 @@ module Net
575
622
  private
576
623
 
577
624
  def tcp_socket(address, port)
578
- TCPSocket.open address, port
625
+ begin
626
+ Socket.tcp address, port, nil, nil, connect_timeout: @open_timeout
627
+ rescue Errno::ETIMEDOUT #raise Net:OpenTimeout instead for compatibility with previous versions
628
+ raise Net::OpenTimeout, "Timeout to open TCP connection to "\
629
+ "#{address}:#{port} (exceeds #{@open_timeout} seconds)"
630
+ end
579
631
  end
580
632
 
581
633
  def do_start(helo_domain, user, secret, authtype)
@@ -584,17 +636,14 @@ module Net
584
636
  check_auth_method(authtype || DEFAULT_AUTH_TYPE)
585
637
  check_auth_args user, secret
586
638
  end
587
- s = Timeout.timeout(@open_timeout, Net::OpenTimeout) do
588
- tcp_socket(@address, @port)
589
- end
639
+ s = tcp_socket(@address, @port)
590
640
  logging "Connection opened: #{@address}:#{@port}"
591
641
  @socket = new_internet_message_io(tls? ? tlsconnect(s, @ssl_context_tls) : s)
592
642
  check_response critical { recv_response() }
593
643
  do_helo helo_domain
594
644
  if ! tls? and (starttls_always? or (capable_starttls? and starttls_auto?))
595
645
  unless capable_starttls?
596
- raise SMTPUnsupportedCommand,
597
- "STARTTLS is not supported on this server"
646
+ raise SMTPUnsupportedCommand.new(nil, message: "STARTTLS is not supported on this server")
598
647
  end
599
648
  starttls
600
649
  @socket = new_internet_message_io(tlsconnect(s, @ssl_context_starttls))
@@ -620,11 +669,8 @@ module Net
620
669
  s = ssl_socket(s, context)
621
670
  logging "TLS connection started"
622
671
  s.sync_close = true
623
- s.hostname = @tls_hostname || @address if s.respond_to? :hostname=
672
+ s.hostname = @tls_hostname || @address
624
673
  ssl_socket_connect(s, @open_timeout)
625
- if context.verify_mode && context.verify_mode != OpenSSL::SSL::VERIFY_NONE
626
- s.post_connection_check(@tls_hostname || @address)
627
- end
628
674
  verified = true
629
675
  s
630
676
  ensure
@@ -669,9 +715,9 @@ module Net
669
715
  # binary message with this method. +msgstr+ should include both
670
716
  # the message headers and body.
671
717
  #
672
- # +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.
673
719
  #
674
- # +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
675
721
  # the destination mail address or addresses.
676
722
  #
677
723
  # === Example
@@ -682,6 +728,12 @@ module Net
682
728
  # ['dest@example.com', 'dest2@example.com']
683
729
  # end
684
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
+ #
685
737
  # === Errors
686
738
  #
687
739
  # This method may raise:
@@ -718,9 +770,9 @@ module Net
718
770
  #
719
771
  # === Parameters
720
772
  #
721
- # +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.
722
774
  #
723
- # +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
724
776
  # the destination mail address or addresses.
725
777
  #
726
778
  # === Example
@@ -870,8 +922,10 @@ module Net
870
922
  getok("EHLO #{domain}")
871
923
  end
872
924
 
925
+ # +from_addr+ is +String+ or +Net::SMTP::Address+
873
926
  def mailfrom(from_addr)
874
- getok("MAIL FROM:<#{from_addr}>")
927
+ addr = Address.new(from_addr)
928
+ getok((["MAIL FROM:<#{addr.address}>"] + addr.parameters).join(' '))
875
929
  end
876
930
 
877
931
  def rcptto_list(to_addrs)
@@ -882,7 +936,7 @@ module Net
882
936
  begin
883
937
  rcptto addr
884
938
  rescue SMTPAuthenticationError
885
- unknown_users << addr.dump
939
+ unknown_users << addr.to_s.dump
886
940
  else
887
941
  ok_users << addr
888
942
  end
@@ -895,8 +949,10 @@ module Net
895
949
  ret
896
950
  end
897
951
 
952
+ # +to_addr+ is +String+ or +Net::SMTP::Address+
898
953
  def rcptto(to_addr)
899
- getok("RCPT TO:<#{to_addr}>")
954
+ addr = Address.new(to_addr)
955
+ getok((["RCPT TO:<#{addr.address}>"] + addr.parameters).join(' '))
900
956
  end
901
957
 
902
958
  # This method sends a message.
@@ -1000,25 +1056,25 @@ module Net
1000
1056
 
1001
1057
  def check_response(res)
1002
1058
  unless res.success?
1003
- raise res.exception_class, res.message
1059
+ raise res.exception_class.new(res)
1004
1060
  end
1005
1061
  end
1006
1062
 
1007
1063
  def check_continue(res)
1008
1064
  unless res.continue?
1009
- raise SMTPUnknownError, "could not get 3xx (#{res.status}: #{res.string})"
1065
+ raise SMTPUnknownError.new(res, message: "could not get 3xx (#{res.status}: #{res.string})")
1010
1066
  end
1011
1067
  end
1012
1068
 
1013
1069
  def check_auth_response(res)
1014
1070
  unless res.success?
1015
- raise SMTPAuthenticationError, res.message
1071
+ raise SMTPAuthenticationError.new(res)
1016
1072
  end
1017
1073
  end
1018
1074
 
1019
1075
  def check_auth_continue(res)
1020
1076
  unless res.continue?
1021
- raise res.exception_class, res.message
1077
+ raise res.exception_class.new(res)
1022
1078
  end
1023
1079
  end
1024
1080
 
@@ -1105,6 +1161,33 @@ module Net
1105
1161
  @debug_output << msg + "\n" if @debug_output
1106
1162
  end
1107
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
+
1108
1191
  end # class SMTP
1109
1192
 
1110
1193
  SMTPSession = SMTP # :nodoc:
data/net-smtp.gemspec CHANGED
@@ -17,17 +17,19 @@ 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
24
24
 
25
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
26
- `git ls-files -z 2>/dev/null`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
27
- end
28
- spec.bindir = "exe"
29
- 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
+ ]
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"
33
35
  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.2.1
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yukihiro Matsumoto
8
8
  autorequire:
9
- bindir: exe
9
+ bindir: bin
10
10
  cert_chain: []
11
- date: 2020-11-18 00:00:00.000000000 Z
11
+ date: 2021-12-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: net-protocol
@@ -24,6 +24,34 @@ 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'
27
55
  description: Simple Mail Transfer Protocol client library for Ruby.
28
56
  email:
29
57
  - matz@ruby-lang.org
@@ -31,15 +59,7 @@ executables: []
31
59
  extensions: []
32
60
  extra_rdoc_files: []
33
61
  files:
34
- - ".github/workflows/test.yml"
35
- - ".gitignore"
36
- - Gemfile
37
62
  - LICENSE.txt
38
- - NEWS.md
39
- - README.md
40
- - Rakefile
41
- - bin/console
42
- - bin/setup
43
63
  - lib/net/smtp.rb
44
64
  - net-smtp.gemspec
45
65
  homepage: https://github.com/ruby/net-smtp
@@ -57,14 +77,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
57
77
  requirements:
58
78
  - - ">="
59
79
  - !ruby/object:Gem::Version
60
- version: 2.5.0
80
+ version: 2.6.0
61
81
  required_rubygems_version: !ruby/object:Gem::Requirement
62
82
  requirements:
63
83
  - - ">="
64
84
  - !ruby/object:Gem::Version
65
85
  version: '0'
66
86
  requirements: []
67
- rubygems_version: 3.2.0.rc.2
87
+ rubygems_version: 3.3.0.dev
68
88
  signing_key:
69
89
  specification_version: 4
70
90
  summary: Simple Mail Transfer Protocol client library for Ruby.
@@ -1,24 +0,0 @@
1
- name: test
2
-
3
- on: [push, pull_request]
4
-
5
- jobs:
6
- build:
7
- name: build (${{ matrix.ruby }} / ${{ matrix.os }})
8
- strategy:
9
- matrix:
10
- ruby: [ 2.7, 2.6, 2.5, head ]
11
- os: [ ubuntu-latest, macos-latest ]
12
- runs-on: ${{ matrix.os }}
13
- steps:
14
- - uses: actions/checkout@master
15
- - name: Set up Ruby
16
- uses: ruby/setup-ruby@v1
17
- with:
18
- ruby-version: ${{ matrix.ruby }}
19
- - name: Install dependencies
20
- run: |
21
- gem install bundler --no-document
22
- bundle install
23
- - name: Run test
24
- run: rake test
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/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/NEWS.md DELETED
@@ -1,44 +0,0 @@
1
- # NEWS
2
-
3
- ## Version 0.2.0 (2020-11-15)
4
-
5
- ### Incompatible changes
6
-
7
- * Verify the server's certificate by default.
8
- If you don't want verification, specify `start(tls_verify: false)`.
9
- <https://github.com/ruby/net-smtp/pull/12>
10
-
11
- * Use STARTTLS by default if possible.
12
- If you don't want starttls, specify:
13
- ```
14
- smtp = Net::SMTP.new(hostname, port)
15
- smtp.disable_starttls
16
- smtp.start do |s|
17
- s.send_message ....
18
- end
19
- ```
20
- <https://github.com/ruby/net-smtp/pull/9>
21
-
22
- ### Improvements
23
-
24
- * Net::SMTP.start and Net::SMTP#start arguments are keyword arguments.
25
- ```
26
- start(address, port = nil, helo: 'localhost', user: nil, secret: nil, authtype: nil) { |smtp| ... }
27
- ```
28
- `password` is an alias of `secret`.
29
- <https://github.com/ruby/net-smtp/pull/7>
30
-
31
- * Add `tls_hostname` parameter to `start()`.
32
- If you want to use a different hostname than the certificate for the connection, you can specify the certificate hostname with `tls_hostname`.
33
- <https://github.com/ruby/net-smtp/pull/14>
34
-
35
- * Add SNI support to net/smtp <https://github.com/ruby/net-smtp/pull/4>
36
-
37
- ### Fixes
38
-
39
- * enable_starttls before disable_tls causes an error. <https://github.com/ruby/net-smtp/pull/10>
40
- * TLS should not check the hostname when verify_mode is disabled. <https://github.com/ruby/net-smtp/pull/6>
41
-
42
- ## Version 0.1.0 (2019-12-03)
43
-
44
- This is the first release of net-smtp gem.
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/ruby/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