@@ -722,34 +722,79 @@ class << self
722
722
# The port this client connected to
723
723
attr_reader :port
724
724
725
- # :call-seq:
726
- # Net::IMAP.new(host, options = {})
727
- #
728
725
# Creates a new Net::IMAP object and connects it to the specified
729
726
# +host+.
730
727
#
731
- # +options+ is an option hash, each key of which is a symbol.
732
- #
733
- # The available options are:
728
+ # ==== Options
729
+ #
730
+ # Accepts the following options:
731
+ #
732
+ # [port]
733
+ # Port number. Defaults to 993 when +ssl+ is truthy, and 143 otherwise.
734
+ #
735
+ # [ssl]
736
+ # If +true+, the connection will use TLS with the default params set by
737
+ # {OpenSSL::SSL::SSLContext#set_params}[https://docs.ruby-lang.org/en/master/OpenSSL/SSL/SSLContext.html#method-i-set_params].
738
+ # If +ssl+ is a hash, it's passed to
739
+ # {OpenSSL::SSL::SSLContext#set_params}[https://docs.ruby-lang.org/en/master/OpenSSL/SSL/SSLContext.html#method-i-set_params];
740
+ # the keys are names of attribute assignment methods on
741
+ # SSLContext[https://docs.ruby-lang.org/en/master/OpenSSL/SSL/SSLContext.html].
742
+ #
743
+ # [open_timeout]
744
+ # Seconds to wait until a connection is opened
745
+ # [idle_response_timeout]
746
+ # Seconds to wait until an IDLE response is received
747
+ #
748
+ # See DeprecatedClientOptions for obsolete backwards compatible arguments.
749
+ #
750
+ # ==== Examples
751
+ #
752
+ # Connect to cleartext port 143 at mail.example.com and recieve the server greeting:
753
+ # imap = Net::IMAP.new('mail.example.com', ssl: false) # => #<Net::IMAP:0x00007f79b0872bd0>
754
+ # imap.port => 143
755
+ # imap.tls_verified? => false
756
+ # imap.greeting => name: ("OK" | "PREAUTH") => status
757
+ # status # => "OK"
758
+ # # The client is connected in the "Not Authenticated" state.
759
+ #
760
+ # Connect with TLS to port 993 at mail.example.com:
761
+ # imap = Net::IMAP.new('mail.example.com', ssl: true) # => #<Net::IMAP:0x00007f79b0872bd0>
762
+ # imap.port => 993
763
+ # imap.tls_verified? => true
764
+ # imap.greeting => name: ("OK" | "PREAUTH") => status
765
+ # status # => "OK"
766
+ # # The client is connected in the "Not Authenticated" state.
767
+ #
768
+ # Connect with prior authentication, for example using an SSL certificate:
769
+ # ssl_ctx_params = {
770
+ # cert: OpenSSL::X509::Certificate.new(File.read("client.crt")),
771
+ # key: OpenSSL::PKey::EC.new(File.read('client.key')),
772
+ # extra_chain_cert: [
773
+ # OpenSSL::X509::Certificate.new(File.read("intermediate.crt")),
774
+ # ],
775
+ # }
776
+ # imap = Net::IMAP.new('mail.example.com', ssl: ssl_ctx_params)
777
+ # imap.port => 993
778
+ # imap.tls_verified? => true
779
+ # imap.greeting => name: "PREAUTH"
780
+ # # The client is connected in the "Authenticated" state.
734
781
#
735
- # port:: Port number (default value is 143 for imap, or 993 for imaps)
736
- # ssl:: If +options[:ssl]+ is true, then an attempt will be made
737
- # to use SSL (now TLS) to connect to the server.
738
- # If +options[:ssl]+ is a hash, it's passed to
739
- # OpenSSL::SSL::SSLContext#set_params as parameters.
740
- # open_timeout:: Seconds to wait until a connection is opened
741
- # idle_response_timeout:: Seconds to wait until an IDLE response is received
782
+ # ==== Exceptions
742
783
#
743
784
# The most common errors are:
744
785
#
745
- # Errno::ECONNREFUSED:: Connection refused by +host+ or an intervening
746
- # firewall.
747
- # Errno::ETIMEDOUT:: Connection timed out (possibly due to packets
748
- # being dropped by an intervening firewall).
749
- # Errno::ENETUNREACH:: There is no route to that network.
750
- # SocketError:: Hostname not known or other socket error.
751
- # Net::IMAP::ByeResponseError:: The connected to the host was successful, but
752
- # it immediately said goodbye.
786
+ # [Errno::ECONNREFUSED]
787
+ # Connection refused by +host+ or an intervening firewall.
788
+ # [Errno::ETIMEDOUT]
789
+ # Connection timed out (possibly due to packets being dropped by an
790
+ # intervening firewall).
791
+ # [Errno::ENETUNREACH]
792
+ # There is no route to that network.
793
+ # [SocketError]
794
+ # Hostname not known or other socket error.
795
+ # [Net::IMAP::ByeResponseError]
796
+ # Connected to the host successfully, but it immediately said goodbye.
797
+ #
753
798
def initialize ( host , port_or_options = { } ,
754
799
usessl = false , certs = nil , verify = true )
755
800
super ( )
0 commit comments