@@ -435,14 +435,20 @@ def login(user, password)
435
435
# in the +mailbox+ can be accessed.
436
436
#
437
437
# After you have selected a mailbox, you may retrieve the
438
- # number of items in that mailbox from + @responses["EXISTS"][-1]+ ,
439
- # and the number of recent messages from + @responses["RECENT"][-1]+ .
438
+ # number of items in that mailbox from <code> @responses["EXISTS"][-1]</code> ,
439
+ # and the number of recent messages from <code> @responses["RECENT"][-1]</code> .
440
440
# Note that these values can change if new messages arrive
441
441
# during a session; see #add_response_handler for a way of
442
442
# detecting this event.
443
443
#
444
444
# A Net::IMAP::NoResponseError is raised if the mailbox does not
445
445
# exist or is for some reason non-selectable.
446
+ #
447
+ # If the server supports the [UIDPLUS[https://www.rfc-editor.org/rfc/rfc4315.html]]
448
+ # extension it may return an additional "NO" response with a "UIDNOTSTICKY" response code
449
+ # indicating that the mailstore does not support persistent UIDs
450
+ # [1[https://www.rfc-editor.org/rfc/rfc4315.html#page-4]]:
451
+ # @responses["NO"].last.code.name == "UIDNOTSTICKY"
446
452
def select ( mailbox )
447
453
synchronize do
448
454
@responses . clear
@@ -752,14 +758,23 @@ def status(mailbox, attr)
752
758
# A Net::IMAP::NoResponseError is raised if the mailbox does
753
759
# not exist (it is not created automatically), or if the flags,
754
760
# date_time, or message arguments contain errors.
761
+ #
762
+ # If the server supports the [UIDPLUS[https://www.rfc-editor.org/rfc/rfc4315.html]]
763
+ # extension it returns an array with the UIDVALIDITY and the assigned UID of the
764
+ # appended message.
755
765
def append ( mailbox , message , flags = nil , date_time = nil )
756
766
args = [ ]
757
767
if flags
758
768
args . push ( flags )
759
769
end
760
770
args . push ( date_time ) if date_time
761
771
args . push ( Literal . new ( message ) )
762
- send_command ( "APPEND" , mailbox , *args )
772
+ synchronize do
773
+ resp = send_command ( "APPEND" , mailbox , *args )
774
+ if resp . data . code && resp . data . code . name == "APPENDUID"
775
+ return resp . data . code . data
776
+ end
777
+ end
763
778
end
764
779
765
780
# Sends a CHECK command to request a checkpoint of the currently
@@ -786,6 +801,32 @@ def expunge
786
801
end
787
802
end
788
803
804
+ # Similar to #expunge, but takes a set of unique identifiers as
805
+ # argument. Sends a UID EXPUNGE command to permanently remove all
806
+ # messages that have both the \\Deleted flag set and a UID that is
807
+ # included in +uid_set+.
808
+ #
809
+ # By using UID EXPUNGE instead of EXPUNGE when resynchronizing with
810
+ # the server, the client can ensure that it does not inadvertantly
811
+ # remove any messages that have been marked as \\Deleted by other
812
+ # clients between the time that the client was last connected and
813
+ # the time the client resynchronizes.
814
+ #
815
+ # Note:: Although the command takes a +uid_set+ for its argument, the
816
+ # server still returns regular EXPUNGE responses, which contain
817
+ # a <em>sequence number</em>. These will be deleted from
818
+ # #responses and this method returns them as an array of
819
+ # <em>sequence number</em> integers.
820
+ #
821
+ # ==== Required capability
822
+ # +UIDPLUS+ - described in [UIDPLUS[https://www.rfc-editor.org/rfc/rfc4315.html]].
823
+ def uid_expunge ( uid_set )
824
+ synchronize do
825
+ send_command ( "UID EXPUNGE" , MessageSet . new ( uid_set ) )
826
+ return @responses . delete ( "EXPUNGE" )
827
+ end
828
+ end
829
+
789
830
# Sends a SEARCH command to search the mailbox for messages that
790
831
# match the given searching criteria, and returns message sequence
791
832
# numbers. +keys+ can either be a string holding the entire
@@ -906,6 +947,10 @@ def uid_store(set, attr, flags)
906
947
# of the specified destination +mailbox+. The +set+ parameter is
907
948
# a number, an array of numbers, or a Range object. The number is
908
949
# a message sequence number.
950
+ #
951
+ # If the server supports the [UIDPLUS[https://www.rfc-editor.org/rfc/rfc4315.html]]
952
+ # extension it returns an array with the UIDVALIDITY, the UID set of the source messages
953
+ # and the assigned UID set of the copied messages.
909
954
def copy ( set , mailbox )
910
955
copy_internal ( "COPY" , set , mailbox )
911
956
end
@@ -921,6 +966,10 @@ def uid_copy(set, mailbox)
921
966
# a message sequence number.
922
967
#
923
968
# The MOVE extension is described in [EXT-MOVE[https://tools.ietf.org/html/rfc6851]].
969
+ #
970
+ # If the server supports the [UIDPLUS[https://www.rfc-editor.org/rfc/rfc4315.html]]
971
+ # extension it returns an array with the UIDVALIDITY, the UID set of the source messages
972
+ # and the assigned UID set of the moved messages.
924
973
def move ( set , mailbox )
925
974
copy_internal ( "MOVE" , set , mailbox )
926
975
end
@@ -1383,7 +1432,12 @@ def store_internal(cmd, set, attr, flags)
1383
1432
end
1384
1433
1385
1434
def copy_internal ( cmd , set , mailbox )
1386
- send_command ( cmd , MessageSet . new ( set ) , mailbox )
1435
+ synchronize do
1436
+ resp = send_command ( cmd , MessageSet . new ( set ) , mailbox )
1437
+ if resp . data . code && resp . data . code . name == "COPYUID"
1438
+ return resp . data . code . data
1439
+ end
1440
+ end
1387
1441
end
1388
1442
1389
1443
def sort_internal ( cmd , sort_keys , search_keys , charset )
0 commit comments