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
@@ -932,22 +942,24 @@ def expunge
932
942
933
943
# Similar to #expunge, but takes a set of unique identifiers as
934
944
# argument. Sends a UID EXPUNGE command to permanently remove all
935
- # messages that have both the \\Deleted flag set and a UID that is
945
+ # messages that have both the <tt> \\Deleted</tt> flag set and a UID that is
936
946
# included in +uid_set+.
937
947
#
938
948
# By using UID EXPUNGE instead of EXPUNGE when resynchronizing with
939
949
# the server, the client can ensure that it does not inadvertantly
940
- # remove any messages that have been marked as \\Deleted by other
950
+ # remove any messages that have been marked as <tt> \\Deleted</tt> by other
941
951
# clients between the time that the client was last connected and
942
952
# the time the client resynchronizes.
943
953
#
944
- # Note:: Although the command takes a +uid_set+ for its argument, the
954
+ # *Note:*
955
+ # >>>
956
+ # Although the command takes a +uid_set+ for its argument, the
945
957
# server still returns regular EXPUNGE responses, which contain
946
958
# a <em>sequence number</em>. These will be deleted from
947
959
# #responses and this method returns them as an array of
948
960
# <em>sequence number</em> integers.
949
961
#
950
- # ==== Capability requirement
962
+ # ===== Capability requirement
951
963
#
952
964
# +UIDPLUS+ [RFC4315[https://www.rfc-editor.org/rfc/rfc4315.html]] must be
953
965
# supported by the server.
@@ -962,12 +974,17 @@ def uid_expunge(uid_set)
962
974
# match the given searching criteria, and returns message sequence
963
975
# numbers. +keys+ can either be a string holding the entire
964
976
# search string, or a single-dimension array of search keywords and
965
- # arguments. The following are some common search criteria;
966
- # see [IMAP] section 6.4.4 for a full list.
977
+ # arguments.
978
+ #
979
+ # ===== Search criteria
980
+ #
981
+ # The following are some common search criteria;
982
+ # see [{IMAP4rev1 §6.4.4}[https://www.rfc-editor.org/rfc/rfc3501.html#section-6.4.4]]
983
+ # for a full list:
967
984
#
968
- # <message set>:: a set of message sequence numbers. ',' indicates
969
- # an interval, ':' indicates a range. For instance,
970
- # ' 2,10:12,15' means "2,10,11,12,15".
985
+ # <message set>:: a set of message sequence numbers. "<tt>,</tt>" indicates
986
+ # an interval, "+:+" indicates a range. For instance,
987
+ # "<tt> 2,10:12,15</tt>" means "<tt> 2,10,11,12,15</tt> ".
971
988
#
972
989
# BEFORE <date>:: messages with an internal date strictly before
973
990
# <date>. The date argument has a format similar
@@ -994,10 +1011,11 @@ def uid_expunge(uid_set)
994
1011
#
995
1012
# TO <string>:: messages with <string> in their TO field.
996
1013
#
997
- # For example:
1014
+ # ===== For example:
998
1015
#
999
1016
# p imap.search(["SUBJECT", "hello", "NOT", "NEW"])
1000
1017
# #=> [1, 6, 7, 8]
1018
+ #
1001
1019
def search ( keys , charset = nil )
1002
1020
return search_internal ( "SEARCH" , keys , charset )
1003
1021
end
@@ -1020,9 +1038,9 @@ def uid_search(keys, charset = nil)
1020
1038
# equivalent to 1..5.
1021
1039
#
1022
1040
# +attr+ is a list of attributes to fetch; see the documentation
1023
- # for Net::IMAP:: FetchData for a list of valid attributes.
1041
+ # for FetchData for a list of valid attributes.
1024
1042
#
1025
- # The return value is an array of Net::IMAP:: FetchData or nil
1043
+ # The return value is an array of FetchData or nil
1026
1044
# (instead of an empty array) if there is no matching message.
1027
1045
#
1028
1046
# For example:
@@ -1059,7 +1077,7 @@ def uid_fetch(set, attr, mod = nil)
1059
1077
# with the provided one, '+FLAGS' will add the provided flags,
1060
1078
# and '-FLAGS' will remove them. +flags+ is a list of flags.
1061
1079
#
1062
- # The return value is an array of Net::IMAP:: FetchData. For example:
1080
+ # The return value is an array of FetchData. For example:
1063
1081
#
1064
1082
# p imap.store(6..8, "+FLAGS", [:Deleted])
1065
1083
# #=> [#<Net::IMAP::FetchData seqno=6, attr={"FLAGS"=>[:Seen, :Deleted]}>, \\
@@ -1079,7 +1097,7 @@ def uid_store(set, attr, flags)
1079
1097
# a number, an array of numbers, or a Range object. The number is
1080
1098
# a message sequence number.
1081
1099
#
1082
- # ==== Capabilities
1100
+ # ===== Capabilities
1083
1101
#
1084
1102
# If +UIDPLUS+ [RFC4315[https://www.rfc-editor.org/rfc/rfc4315.html]] is
1085
1103
# supported, the server's response should include a +COPYUID+ response code
@@ -1091,7 +1109,7 @@ def copy(set, mailbox)
1091
1109
1092
1110
# Similar to #copy, but +set+ contains unique identifiers.
1093
1111
#
1094
- # ==== Capabilities
1112
+ # ===== Capabilities
1095
1113
#
1096
1114
# +UIDPLUS+ affects #uid_copy the same way it affects #copy.
1097
1115
def uid_copy ( set , mailbox )
@@ -1103,7 +1121,7 @@ def uid_copy(set, mailbox)
1103
1121
# a number, an array of numbers, or a Range object. The number is
1104
1122
# a message sequence number.
1105
1123
#
1106
- # ==== Capabilities requirements
1124
+ # ===== Capabilities requirements
1107
1125
#
1108
1126
# +MOVE+ [RFC6851[https://tools.ietf.org/html/rfc6851]] must be supported by
1109
1127
# the server.
@@ -1119,7 +1137,7 @@ def move(set, mailbox)
1119
1137
1120
1138
# Similar to #move, but +set+ contains unique identifiers.
1121
1139
#
1122
- # ==== Capabilities requirements
1140
+ # ===== Capabilities requirements
1123
1141
#
1124
1142
# Same as #move: +MOVE+ [RFC6851[https://tools.ietf.org/html/rfc6851]] must
1125
1143
# be supported by the server. +UIDPLUS+ also affects #uid_move the same way
@@ -1171,8 +1189,7 @@ def remove_response_handler(handler)
1171
1189
end
1172
1190
1173
1191
# Similar to #search, but returns message sequence numbers in threaded
1174
- # format, as a Net::IMAP::ThreadMember tree. The supported algorithms
1175
- # are:
1192
+ # format, as a ThreadMember tree. The supported algorithms are:
1176
1193
#
1177
1194
# ORDEREDSUBJECT:: split into single-level threads according to subject,
1178
1195
# ordered by date.
0 commit comments