23
23
24
24
module Net
25
25
26
- #
27
- # Net::IMAP implements Internet Message Access Protocol (IMAP) client
26
+ # Net::IMAP implements Internet Message Access Protocol (\IMAP) client
28
27
# functionality. The protocol is described in
29
- # [IMAP[https://tools.ietf.org/html/rfc3501]].
28
+ # [IMAP4rev1[https://tools.ietf.org/html/rfc3501]].
29
+ #--
30
+ # TODO: and [IMAP4rev2[https://tools.ietf.org/html/rfc9051]].
31
+ #++
30
32
#
31
- # == IMAP Overview
33
+ # == \ IMAP Overview
32
34
#
33
35
# An \IMAP client connects to a server, and then authenticates
34
36
# itself using either #authenticate or #login. Having
@@ -41,12 +43,14 @@ module Net
41
43
# within a hierarchy of directories.
42
44
#
43
45
# To work on the messages within a mailbox, the client must
44
- # first select that mailbox, using either #select or (for
45
- # read-only access) #examine . Once the client has successfully
46
- # selected a mailbox, they enter _selected_ state, and that
46
+ # first select that mailbox, using either #select or #examine
47
+ # (for read-only access). Once the client has successfully
48
+ # selected a mailbox, they enter the " _selected_" state, and that
47
49
# mailbox becomes the _current_ mailbox, on which mail-item
48
50
# related commands implicitly operate.
49
51
#
52
+ # === Sequence numbers and UIDs
53
+ #
50
54
# Messages have two sorts of identifiers: message sequence
51
55
# numbers and UIDs.
52
56
#
@@ -62,7 +66,7 @@ module Net
62
66
# the existing message is deleted. UIDs are required to
63
67
# be assigned in ascending (but not necessarily sequential)
64
68
# order within a mailbox; this means that if a non-IMAP client
65
- # rearranges the order of mailitems within a mailbox, the
69
+ # rearranges the order of mail items within a mailbox, the
66
70
# UIDs have to be reassigned. An \IMAP client thus cannot
67
71
# rearrange message orders.
68
72
#
@@ -108,15 +112,15 @@ module Net
108
112
#
109
113
# == Errors
110
114
#
111
- # An IMAP server can send three different types of responses to indicate
115
+ # An \ IMAP server can send three different types of responses to indicate
112
116
# failure:
113
117
#
114
118
# NO:: the attempted command could not be successfully completed. For
115
119
# instance, the username/password used for logging in are incorrect;
116
120
# the selected mailbox does not exist; etc.
117
121
#
118
122
# BAD:: the request from the client does not follow the server's
119
- # understanding of the IMAP protocol. This includes attempting
123
+ # understanding of the \ IMAP protocol. This includes attempting
120
124
# commands from the wrong client state; for instance, attempting
121
125
# to perform a SEARCH command without having SELECTed a current
122
126
# mailbox. It can also signal an internal server
@@ -340,10 +344,12 @@ class IMAP < Protocol
340
344
include SSL
341
345
end
342
346
343
- # Returns an initial greeting response from the server.
347
+ # Returns the initial greeting the server, an UntaggedResponse .
344
348
attr_reader :greeting
345
349
346
- # Returns recorded untagged responses. For example:
350
+ # Returns recorded untagged responses.
351
+ #
352
+ # For example:
347
353
#
348
354
# imap.select("inbox")
349
355
# p imap.responses["EXISTS"][-1]
@@ -421,14 +427,17 @@ def disconnected?
421
427
422
428
# Sends a CAPABILITY command, and returns an array of
423
429
# capabilities that the server supports. Each capability
424
- # is a string. See [IMAP] for a list of possible
425
- # capabilities.
426
- #
427
- # Note that the Net::IMAP class does not modify its
428
- # behaviour according to the capabilities of the server;
429
- # it is up to the user of the class to ensure that
430
- # a certain capability is supported by a server before
431
- # using it.
430
+ # is a string.
431
+ # See the {IANA IMAP capabilities registry}[https://www.iana.org/assignments/imap-capabilities/imap-capabilities.xhtml]
432
+ # for a list of possible capabilities and their RFCs.
433
+ #
434
+ # >>>
435
+ # <em>*Note* that the Net::IMAP class does not modify its
436
+ # behaviour according to the capabilities of the server;
437
+ # it is up to the user of the class to ensure that
438
+ # a certain capability is supported by a server before
439
+ # using it.</em>
440
+ #
432
441
def capability
433
442
synchronize do
434
443
send_command ( "CAPABILITY" )
@@ -492,10 +501,10 @@ def starttls(options = {}, verify = true)
492
501
# supports the following mechanisms:
493
502
#
494
503
# PLAIN:: Login using cleartext user and password. Secure with TLS.
495
- # See Net::IMAP:: PlainAuthenticator.
504
+ # See PlainAuthenticator.
496
505
# CRAM-MD5:: DEPRECATED: Use PLAIN (or DIGEST-MD5) with TLS.
497
506
# DIGEST-MD5:: DEPRECATED by RFC6331. Must be secured using TLS.
498
- # See Net::IMAP:: DigestMD5Authenticator.
507
+ # See DigestMD5Authenticator.
499
508
# LOGIN:: DEPRECATED: Use PLAIN.
500
509
#
501
510
# Most mechanisms require two args: authentication identity (e.g. username)
@@ -518,7 +527,7 @@ def starttls(options = {}, verify = true)
518
527
#
519
528
# A Net::IMAP::NoResponseError is raised if authentication fails.
520
529
#
521
- # See + Net::IMAP::Authenticators+ for more information on plugging in your
530
+ # See Net::IMAP::Authenticators for more information on plugging in your
522
531
# own authenticator.
523
532
def authenticate ( auth_type , *args )
524
533
authenticator = self . class . authenticator ( auth_type , *args )
@@ -555,7 +564,7 @@ def login(user, password)
555
564
# A Net::IMAP::NoResponseError is raised if the mailbox does not
556
565
# exist or is for some reason non-selectable.
557
566
#
558
- # ==== Capabilities
567
+ # ===== Capabilities
559
568
#
560
569
# If [UIDPLUS[https://www.rfc-editor.org/rfc/rfc4315.html]] is supported,
561
570
# the server may return an untagged "NO" response with a "UIDNOTSTICKY"
@@ -644,7 +653,7 @@ def unsubscribe(mailbox)
644
653
# which mailboxes to match. If +mailbox+ is empty, the root
645
654
# name of +refname+ and the hierarchy delimiter are returned.
646
655
#
647
- # The return value is an array of +Net::IMAP:: MailboxList+ . For example:
656
+ # The return value is an array of MailboxList. For example:
648
657
#
649
658
# imap.create("foo/bar")
650
659
# imap.create("foo/baz")
@@ -688,9 +697,9 @@ def list(refname, mailbox)
688
697
# create the mailbox in.
689
698
#
690
699
# The user of this method should first check if the server supports the
691
- # NAMESPACE capability. The return value is a +Net::IMAP:: Namespaces+
700
+ # NAMESPACE # capability. The return value is a Namespaces
692
701
# object which has +personal+, +other+, and +shared+ fields, each an array
693
- # of +Net::IMAP:: Namespace+ objects. These arrays will be empty when the
702
+ # of Namespace objects. These arrays will be empty when the
694
703
# server responds with nil.
695
704
#
696
705
# For example:
@@ -733,7 +742,7 @@ def namespace
733
742
# The XLIST command is like the LIST command except that the flags
734
743
# returned refer to the function of the folder/mailbox, e.g. :Sent
735
744
#
736
- # The return value is an array of +Net::IMAP:: MailboxList+ . For example:
745
+ # The return value is an array of MailboxList objects . For example:
737
746
#
738
747
# imap.create("foo/bar")
739
748
# imap.create("foo/baz")
@@ -751,7 +760,7 @@ def xlist(refname, mailbox)
751
760
# Sends the GETQUOTAROOT command along with the specified +mailbox+.
752
761
# This command is generally available to both admin and user.
753
762
# If this mailbox exists, it returns an array containing objects of type
754
- # Net::IMAP:: MailboxQuotaRoot and Net::IMAP:: MailboxQuota.
763
+ # MailboxQuotaRoot and MailboxQuota.
755
764
#
756
765
# The QUOTA extension is described in [QUOTA[https://tools.ietf.org/html/rfc2087]]
757
766
def getquotaroot ( mailbox )
@@ -766,7 +775,7 @@ def getquotaroot(mailbox)
766
775
767
776
# Sends the GETQUOTA command along with specified +mailbox+.
768
777
# If this mailbox exists, then an array containing a
769
- # Net::IMAP:: MailboxQuota object is returned. This
778
+ # MailboxQuota object is returned. This
770
779
# command is generally only available to server admin.
771
780
#
772
781
# The QUOTA extension is described in [QUOTA[https://tools.ietf.org/html/rfc2087]]
@@ -807,7 +816,7 @@ def setacl(mailbox, user, rights)
807
816
808
817
# Send the GETACL command along with a specified +mailbox+.
809
818
# If this mailbox exists, an array containing objects of
810
- # Net::IMAP:: MailboxACLItem will be returned.
819
+ # MailboxACLItem will be returned.
811
820
#
812
821
# The ACL extension is described in [ACL[https://tools.ietf.org/html/rfc4314]]
813
822
def getacl ( mailbox )
@@ -822,7 +831,7 @@ def getacl(mailbox)
822
831
# "subscribed." +refname+ and +mailbox+ are interpreted as
823
832
# for #list.
824
833
#
825
- # The return value is an array of +Net::IMAP:: MailboxList+ .
834
+ # The return value is an array of MailboxList objects .
826
835
def lsub ( refname , mailbox )
827
836
synchronize do
828
837
send_command ( "LSUB" , refname , mailbox )
@@ -858,6 +867,7 @@ def status(mailbox, attr)
858
867
# flags initially passed to the new message. The optional
859
868
# +date_time+ argument specifies the creation time to assign to the
860
869
# new message; it defaults to the current time.
870
+ #
861
871
# For example:
862
872
#
863
873
# imap.append("inbox", <<EOF.gsub(/\n/, "\r\n"), [:Seen], Time.now)
@@ -872,7 +882,7 @@ def status(mailbox, attr)
872
882
# not exist (it is not created automatically), or if the flags,
873
883
# date_time, or message arguments contain errors.
874
884
#
875
- # ==== Capabilities
885
+ # ===== Capabilities
876
886
#
877
887
# If +UIDPLUS+ [RFC4315[https://www.rfc-editor.org/rfc/rfc4315.html]] is
878
888
# supported, the server's response should include a +APPENDUID+ response
@@ -918,22 +928,24 @@ def expunge
918
928
919
929
# Similar to #expunge, but takes a set of unique identifiers as
920
930
# argument. Sends a UID EXPUNGE command to permanently remove all
921
- # messages that have both the \\Deleted flag set and a UID that is
931
+ # messages that have both the <tt> \\Deleted</tt> flag set and a UID that is
922
932
# included in +uid_set+.
923
933
#
924
934
# By using UID EXPUNGE instead of EXPUNGE when resynchronizing with
925
935
# the server, the client can ensure that it does not inadvertantly
926
- # remove any messages that have been marked as \\Deleted by other
936
+ # remove any messages that have been marked as <tt> \\Deleted</tt> by other
927
937
# clients between the time that the client was last connected and
928
938
# the time the client resynchronizes.
929
939
#
930
- # Note:: Although the command takes a +uid_set+ for its argument, the
940
+ # *Note:*
941
+ # >>>
942
+ # Although the command takes a +uid_set+ for its argument, the
931
943
# server still returns regular EXPUNGE responses, which contain
932
944
# a <em>sequence number</em>. These will be deleted from
933
945
# #responses and this method returns them as an array of
934
946
# <em>sequence number</em> integers.
935
947
#
936
- # ==== Capability requirement
948
+ # ===== Capability requirement
937
949
#
938
950
# +UIDPLUS+ [RFC4315[https://www.rfc-editor.org/rfc/rfc4315.html]] must be
939
951
# supported by the server.
@@ -948,12 +960,17 @@ def uid_expunge(uid_set)
948
960
# match the given searching criteria, and returns message sequence
949
961
# numbers. +keys+ can either be a string holding the entire
950
962
# search string, or a single-dimension array of search keywords and
951
- # arguments. The following are some common search criteria;
952
- # see [IMAP] section 6.4.4 for a full list.
963
+ # arguments.
964
+ #
965
+ # ===== Search criteria
953
966
#
954
- # <message set>:: a set of message sequence numbers. ',' indicates
955
- # an interval, ':' indicates a range. For instance,
956
- # '2,10:12,15' means "2,10,11,12,15".
967
+ # The following are some common search criteria;
968
+ # see [{IMAP4rev1 §6.4.4}[https://www.rfc-editor.org/rfc/rfc3501.html#section-6.4.4]]
969
+ # for a full list:
970
+ #
971
+ # <message set>:: a set of message sequence numbers. "<tt>,</tt>" indicates
972
+ # an interval, "+:+" indicates a range. For instance,
973
+ # "<tt>2,10:12,15</tt>" means "<tt>2,10,11,12,15</tt>".
957
974
#
958
975
# BEFORE <date>:: messages with an internal date strictly before
959
976
# <date>. The date argument has a format similar
@@ -980,10 +997,11 @@ def uid_expunge(uid_set)
980
997
#
981
998
# TO <string>:: messages with <string> in their TO field.
982
999
#
983
- # For example:
1000
+ # ===== For example:
984
1001
#
985
1002
# p imap.search(["SUBJECT", "hello", "NOT", "NEW"])
986
1003
# #=> [1, 6, 7, 8]
1004
+ #
987
1005
def search ( keys , charset = nil )
988
1006
return search_internal ( "SEARCH" , keys , charset )
989
1007
end
@@ -1006,9 +1024,9 @@ def uid_search(keys, charset = nil)
1006
1024
# equivalent to 1..5.
1007
1025
#
1008
1026
# +attr+ is a list of attributes to fetch; see the documentation
1009
- # for Net::IMAP:: FetchData for a list of valid attributes.
1027
+ # for FetchData for a list of valid attributes.
1010
1028
#
1011
- # The return value is an array of Net::IMAP:: FetchData or nil
1029
+ # The return value is an array of FetchData or nil
1012
1030
# (instead of an empty array) if there is no matching message.
1013
1031
#
1014
1032
# For example:
@@ -1045,7 +1063,7 @@ def uid_fetch(set, attr, mod = nil)
1045
1063
# with the provided one, '+FLAGS' will add the provided flags,
1046
1064
# and '-FLAGS' will remove them. +flags+ is a list of flags.
1047
1065
#
1048
- # The return value is an array of Net::IMAP:: FetchData. For example:
1066
+ # The return value is an array of FetchData. For example:
1049
1067
#
1050
1068
# p imap.store(6..8, "+FLAGS", [:Deleted])
1051
1069
# #=> [#<Net::IMAP::FetchData seqno=6, attr={"FLAGS"=>[:Seen, :Deleted]}>, \\
@@ -1065,7 +1083,7 @@ def uid_store(set, attr, flags)
1065
1083
# a number, an array of numbers, or a Range object. The number is
1066
1084
# a message sequence number.
1067
1085
#
1068
- # ==== Capabilities
1086
+ # ===== Capabilities
1069
1087
#
1070
1088
# If +UIDPLUS+ [RFC4315[https://www.rfc-editor.org/rfc/rfc4315.html]] is
1071
1089
# supported, the server's response should include a +COPYUID+ response code
@@ -1077,7 +1095,7 @@ def copy(set, mailbox)
1077
1095
1078
1096
# Similar to #copy, but +set+ contains unique identifiers.
1079
1097
#
1080
- # ==== Capabilities
1098
+ # ===== Capabilities
1081
1099
#
1082
1100
# +UIDPLUS+ affects #uid_copy the same way it affects #copy.
1083
1101
def uid_copy ( set , mailbox )
@@ -1089,7 +1107,7 @@ def uid_copy(set, mailbox)
1089
1107
# a number, an array of numbers, or a Range object. The number is
1090
1108
# a message sequence number.
1091
1109
#
1092
- # ==== Capabilities requirements
1110
+ # ===== Capabilities requirements
1093
1111
#
1094
1112
# +MOVE+ [RFC6851[https://tools.ietf.org/html/rfc6851]] must be supported by
1095
1113
# the server.
@@ -1105,7 +1123,7 @@ def move(set, mailbox)
1105
1123
1106
1124
# Similar to #move, but +set+ contains unique identifiers.
1107
1125
#
1108
- # ==== Capabilities requirements
1126
+ # ===== Capabilities requirements
1109
1127
#
1110
1128
# Same as #move: +MOVE+ [RFC6851[https://tools.ietf.org/html/rfc6851]] must
1111
1129
# be supported by the server. +UIDPLUS+ also affects #uid_move the same way
@@ -1157,8 +1175,7 @@ def remove_response_handler(handler)
1157
1175
end
1158
1176
1159
1177
# Similar to #search, but returns message sequence numbers in threaded
1160
- # format, as a Net::IMAP::ThreadMember tree. The supported algorithms
1161
- # are:
1178
+ # format, as a ThreadMember tree. The supported algorithms are:
1162
1179
#
1163
1180
# ORDEREDSUBJECT:: split into single-level threads according to subject,
1164
1181
# ordered by date.
0 commit comments