Package com.sun.mail.imap.protocol
Class IMAPProtocol
java.lang.Object
com.sun.mail.iap.Protocol
com.sun.mail.imap.protocol.IMAPProtocol
- Direct Known Subclasses:
GmailProtocol
This class extends the iap.Protocol object and implements IMAP
semantics. In general, there is a method corresponding to each
IMAP protocol command. The typical implementation issues the
appropriate protocol command, collects all responses, processes
those responses that are specific to this command and then
dispatches the rest (the unsolicited ones) to the dispatcher
using the
notifyResponseHandlers(r)
.- Author:
- John Mani, Bill Shannon
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionIMAPProtocol
(InputStream in, PrintStream out, Properties props, boolean debug) Constructor for debugging.IMAPProtocol
(String name, String host, int port, Properties props, boolean isSSL, MailLogger logger) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
APPEND Command.APPEND Command, return uid from APPENDUID response code.void
The AUTHENTICATE command with AUTH=LOGIN authenticate schemevoid
The AUTHENTICATE command with AUTH=NTLM authentication scheme.void
authoauth2
(String u, String p) The AUTHENTICATE command with AUTH=XOAUTH2 authentication scheme.void
The AUTHENTICATE command with AUTH=PLAIN authentication scheme.void
CAPABILITY command.void
check()
CHECK Command.void
close()
CLOSE Command.void
compress()
COMPRESS Command.void
COPY command.void
copy
(MessageSet[] msgsets, String mbox) COPY command.COPY command, return uid from COPYUID response code.copyuid
(MessageSet[] msgsets, String mbox) COPY command, return uid from COPYUID response code.void
CREATE Command.protected String
createFlagList
(Flags flags) Creates an IMAP flag_list from the given Flags object.void
DELETE Command.void
DELETEACL Command.void
Close socket connection.protected ListInfo[]
Execute the specified LIST-like command (e.g., "LIST" or "LSUB"), using the reference and pattern.void
ENABLE Command.EXAMINE Command.examine
(String mbox, ResyncData rd) EXAMINE Command with QRESYNC data.void
expunge()
EXPUNGE Command.Response[]
Response[]
Response[]
fetch
(MessageSet[] msgsets, String what) Fetch given BODY section.protected BODY
Partial FETCH of given BODY section.protected BODY
Partial FETCH of given BODY section.fetchBodyStructure
(int msgno) Fetch the BODYSTRUCTURE of the specified message.fetchFlags
(int msgno) Fetch the FLAGS for the given message.fetchMODSEQ
(int msgno) Fetch the IMAP MODSEQ for the given message.fetchRFC822
(int msgno, String what) Fetch the specified RFC822 Data item.protected BODY
fetchSectionBody
(int msgno, String section, String body) Fetch the given body section of the given message, using the body string "body".void
fetchSequenceNumber
(long uid) Get the sequence number for the given UID.void
fetchSequenceNumbers
(long[] uids) Get the sequence numbers for UIDs specified in the array.long[]
fetchSequenceNumbers
(long start, long end) Get the sequence numbers for UIDs ranging from start till end.fetchUID
(int msgno) Fetch the IMAP UID for the given message.ACL[]
GETACL Command.Return the map of capabilities returned by the server.protected CopyUID
getCopyUID
(Response[] rr) If the response contains a COPYUID response code, extract it and return a CopyUID object with the information.Return an array of FetchItem objects describing the FETCH items supported by this protocol.Get the user name used with the PROXYAUTH command.Quota[]
GETQUOTA Command.Quota[]
getQuotaRoot
(String mbox) GETQUOTAROOT Command.protected ByteArray
Return a buffer to read a response into.protected SearchSequence
Get the SearchSequence object.void
Handle any untagged CAPABILITY response in the Response array.protected void
Handle the result response for a LOGIN or AUTHENTICATE command.boolean
Check whether the given capability is supported by this server.void
Deprecated.ID Command.void
Abort an IDLE command.void
IDLE Command.boolean
Returnstrue
if the connection has been authenticated, either due to a successful login, or due to a PREAUTH greeting response.boolean
Is the capability/extension enabled?boolean
isREV1()
Returnstrue
if this is an IMAP4rev1 serverListInfo[]
LIST Command.Rights[]
listRights
(String mbox, String user) LISTRIGHTS Command.void
LOGIN Command.void
logout()
LOGOUT Command.ListInfo[]
LSUB Command.void
MOVE command.void
move
(MessageSet[] msgsets, String mbox) MOVE command.MOVE Command, return uid from COPYUID response code.moveuid
(MessageSet[] msgsets, String mbox) MOVE Command, return uid from COPYUID response code.MYRIGHTS Command.NAMESPACE Command.void
noop()
The NOOP command.protected void
Parse the capabilities from a CAPABILITY response or from a CAPABILITY response code attached to (e.g.) an OK response.Fetch given BODY section, without marking the message as SEEN.Partial FETCH of given BODY section, without setting SEEN flag.Partial FETCH of given BODY section, without setting SEEN flag.protected void
Check the greeting when first connecting; look for PREAUTH response.boolean
Process a response returned by readIdleResponse().void
PROXYAUTH Command.While an IDLE command is in progress, read a response sent from the server.Read a response from the server.void
RENAME Command.void
SASL-based login.int[]
search
(MessageSet[] msgsets, SearchTerm term) Issue the given search criterion on the specified message sets.int[]
search
(SearchTerm term) Issue the given search criterion on all messages in this folder.SELECT Command.select
(String mbox, ResyncData rd) SELECT Command with QRESYNC data.void
SETACL Command.protected void
If the response contains a CAPABILITY response code, extract it and save the capabilities.void
SETQUOTA Command.int[]
sort
(SortTerm[] term, SearchTerm sterm) Sort messages in the folder according to the specified sort criteria.void
startTLS()
STARTTLS Command.STATUS Command.void
storeFlags
(int start, int end, Flags flags, boolean set) void
storeFlags
(int msg, Flags flags, boolean set) Set the specified flags on this message.void
storeFlags
(MessageSet[] msgsets, Flags flags, boolean set) void
SUBSCRIBE Command.protected boolean
Returns whether this Protocol supports non-synchronizing literals.boolean
Does the server support UTF-8?void
uidexpunge
(UIDSet[] set) UID EXPUNGE Command.int[]
uidfetchChangedSince
(long start, long end, long modseq) Get the sequence numbers for messages changed since the given modseq and with UIDs ranging from start till end.void
UNAUTHENTICATE Command.void
unselect()
UNSELECT Command.void
unsubscribe
(String mbox) UNSUBSCRIBE Command.protected void
writeMailboxName
(Argument args, String name) Encode a mailbox name appropriately depending on whether or not the server supports UTF-8, and add the encoded name to the Argument.Methods inherited from class com.sun.mail.iap.Protocol
addResponseHandler, command, finalize, getChannel, getInetAddress, getInputStream, getLocalHost, getLocalSocketAddress, getOutputStream, getTimestamp, handleResult, hasResponse, isSSL, isTracing, notifyResponseHandlers, removeResponseHandler, resumeTracing, simpleCommand, startCompression, startTLS, suspendTracing, writeCommand
-
Field Details
-
searchSequence
-
searchCharsets
-
enabled
-
-
Constructor Details
-
IMAPProtocol
public IMAPProtocol(String name, String host, int port, Properties props, boolean isSSL, MailLogger logger) throws IOException, ProtocolException Constructor. Opens a connection to the given host at given port.- Parameters:
name
- the protocol namehost
- host to connect toport
- port number to connect toprops
- Properties object used by this protocolisSSL
- true if SSL should be usedlogger
- the MailLogger to use for debug output- Throws:
IOException
- for I/O errorsProtocolException
- for protocol failures
-
IMAPProtocol
public IMAPProtocol(InputStream in, PrintStream out, Properties props, boolean debug) throws IOException Constructor for debugging.- Parameters:
in
- the InputStream from which to readout
- the PrintStream to which to writeprops
- Properties object used by this protocoldebug
- true to enable debugging output- Throws:
IOException
- for I/O errors
-
-
Method Details
-
getFetchItems
Return an array of FetchItem objects describing the FETCH items supported by this protocol. Subclasses may override this method to combine their FetchItems with the FetchItems returned by the superclass.- Returns:
- an array of FetchItem objects
- Since:
- JavaMail 1.4.6
-
capability
CAPABILITY command.- Throws:
ProtocolException
- for protocol failures- See Also:
-
- "RFC2060, section 6.1.1"
-
handleCapabilityResponse
Handle any untagged CAPABILITY response in the Response array.- Parameters:
r
- the responses
-
setCapabilities
If the response contains a CAPABILITY response code, extract it and save the capabilities.- Parameters:
r
- the response
-
parseCapabilities
Parse the capabilities from a CAPABILITY response or from a CAPABILITY response code attached to (e.g.) an OK response.- Parameters:
r
- the CAPABILITY response
-
processGreeting
Check the greeting when first connecting; look for PREAUTH response.- Overrides:
processGreeting
in classProtocol
- Parameters:
r
- the greeting response- Throws:
ProtocolException
- for protocol failures
-
isAuthenticated
public boolean isAuthenticated()Returnstrue
if the connection has been authenticated, either due to a successful login, or due to a PREAUTH greeting response.- Returns:
- true if the connection has been authenticated
-
isREV1
public boolean isREV1()Returnstrue
if this is an IMAP4rev1 server- Returns:
- true if this is an IMAP4rev1 server
-
supportsNonSyncLiterals
protected boolean supportsNonSyncLiterals()Returns whether this Protocol supports non-synchronizing literals.- Overrides:
supportsNonSyncLiterals
in classProtocol
- Returns:
- true if non-synchronizing literals are supported
-
readResponse
Read a response from the server.- Overrides:
readResponse
in classProtocol
- Returns:
- the response
- Throws:
IOException
- for I/O errorsProtocolException
- for protocol failures
-
hasCapability
Check whether the given capability is supported by this server. Returnstrue
if so, otherwise returns false.- Parameters:
c
- the capability name- Returns:
- true if the server has the capability
-
getCapabilities
Return the map of capabilities returned by the server.- Returns:
- the Map of capabilities
- Since:
- JavaMail 1.4.1
-
supportsUtf8
public boolean supportsUtf8()Does the server support UTF-8?- Overrides:
supportsUtf8
in classProtocol
- Returns:
- true if the server supports UTF-8
- Since:
- JavaMail 1.6.0
-
disconnect
public void disconnect()Close socket connection. This method just makes the Protocol.disconnect() method public.- Overrides:
disconnect
in classProtocol
-
noop
The NOOP command.- Throws:
ProtocolException
- for protocol failures- See Also:
-
- "RFC2060, section 6.1.2"
-
logout
LOGOUT Command.- Throws:
ProtocolException
- for protocol failures- See Also:
-
- "RFC2060, section 6.1.3"
-
login
LOGIN Command.- Parameters:
u
- the usernamep
- the password- Throws:
ProtocolException
- as thrown byProtocol.handleResult(com.sun.mail.iap.Response)
.- See Also:
-
- "RFC2060, section 6.2.2"
-
authlogin
The AUTHENTICATE command with AUTH=LOGIN authenticate scheme- Parameters:
u
- the usernamep
- the password- Throws:
ProtocolException
- as thrown byProtocol.handleResult(com.sun.mail.iap.Response)
.- See Also:
-
- "RFC2060, section 6.2.1"
-
authplain
The AUTHENTICATE command with AUTH=PLAIN authentication scheme. This is based heavly on theauthlogin(java.lang.String, java.lang.String)
method.- Parameters:
authzid
- the authorization idu
- the usernamep
- the password- Throws:
ProtocolException
- as thrown byProtocol.handleResult(com.sun.mail.iap.Response)
.- Since:
- JavaMail 1.3.2
- See Also:
-
- "RFC3501, section 6.2.2"
- "RFC2595, section 6"
-
authntlm
The AUTHENTICATE command with AUTH=NTLM authentication scheme. This is based heavly on theauthlogin(java.lang.String, java.lang.String)
method.- Parameters:
authzid
- the authorization idu
- the usernamep
- the password- Throws:
ProtocolException
- as thrown byProtocol.handleResult(com.sun.mail.iap.Response)
.- Since:
- JavaMail 1.4.3
- See Also:
-
- "RFC3501, section 6.2.2"
- "RFC2595, section 6"
-
authoauth2
The AUTHENTICATE command with AUTH=XOAUTH2 authentication scheme. This is based heavly on theauthlogin(java.lang.String, java.lang.String)
method.- Parameters:
u
- the usernamep
- the password- Throws:
ProtocolException
- as thrown byProtocol.handleResult(com.sun.mail.iap.Response)
.- Since:
- JavaMail 1.5.5
- See Also:
-
- "RFC3501, section 6.2.2"
- "RFC2595, section 6"
-
sasllogin
public void sasllogin(String[] allowed, String realm, String authzid, String u, String p) throws ProtocolException SASL-based login.- Parameters:
allowed
- the SASL mechanisms we're allowed to userealm
- the SASL realmauthzid
- the authorization idu
- the usernamep
- the password- Throws:
ProtocolException
- for protocol failures
-
handleLoginResult
Handle the result response for a LOGIN or AUTHENTICATE command. Look for IMAP login REFERRAL.- Parameters:
r
- the response- Throws:
ProtocolException
- for protocol failures- Since:
- JavaMail 1.5.5
-
proxyauth
PROXYAUTH Command.- Parameters:
u
- the PROXYAUTH user name- Throws:
ProtocolException
- for protocol failures- See Also:
-
- "Netscape/iPlanet/SunONE Messaging Server extension"
-
getProxyAuthUser
Get the user name used with the PROXYAUTH command. Returns null if PROXYAUTH was not used.- Returns:
- the PROXYAUTH user name
- Since:
- JavaMail 1.5.1
-
unauthenticate
UNAUTHENTICATE Command.- Throws:
ProtocolException
- for protocol failures- Since:
- JavaMail 1.5.1
- See Also:
-
- "Netscape/iPlanet/SunONE Messaging Server extension"
-
id
Deprecated.As of JavaMail 1.5.1, replaced byid(Map<String,String>)
ID Command, for Yahoo! Mail IMAP server.- Parameters:
guid
- the GUID- Throws:
ProtocolException
- for protocol failures- Since:
- JavaMail 1.4.4
-
startTLS
STARTTLS Command.- Throws:
ProtocolException
- for protocol failures- See Also:
-
- "RFC3501, section 6.2.1"
-
compress
COMPRESS Command. Only supports DEFLATE.- Throws:
ProtocolException
- for protocol failures- See Also:
-
- "RFC 4978"
-
writeMailboxName
Encode a mailbox name appropriately depending on whether or not the server supports UTF-8, and add the encoded name to the Argument.- Parameters:
args
- the argumentsname
- the name to encode- Since:
- JavaMail 1.6.0
-
select
SELECT Command.- Parameters:
mbox
- the mailbox name- Returns:
- MailboxInfo if successful
- Throws:
ProtocolException
- for protocol failures- See Also:
-
- "RFC2060, section 6.3.1"
-
select
SELECT Command with QRESYNC data.- Parameters:
mbox
- the mailbox namerd
- the ResyncData- Returns:
- MailboxInfo if successful
- Throws:
ProtocolException
- for protocol failures- Since:
- JavaMail 1.5.1
- See Also:
-
- "RFC2060, section 6.3.1"
- "RFC5162, section 3.1"
-
examine
EXAMINE Command.- Parameters:
mbox
- the mailbox name- Returns:
- MailboxInfo if successful
- Throws:
ProtocolException
- for protocol failures- See Also:
-
- "RFC2060, section 6.3.2"
-
examine
EXAMINE Command with QRESYNC data.- Parameters:
mbox
- the mailbox namerd
- the ResyncData- Returns:
- MailboxInfo if successful
- Throws:
ProtocolException
- for protocol failures- Since:
- JavaMail 1.5.1
- See Also:
-
- "RFC2060, section 6.3.2"
- "RFC5162, section 3.1"
-
enable
ENABLE Command.- Parameters:
cap
- the name of the capability to enable- Throws:
ProtocolException
- for protocol failures- Since:
- JavaMail 1.5.1
- See Also:
-
- "RFC 5161"
-
isEnabled
Is the capability/extension enabled?- Parameters:
cap
- the capability name- Returns:
- true if enabled
- Since:
- JavaMail 1.5.1
- See Also:
-
- "RFC 5161"
-
unselect
UNSELECT Command.- Throws:
ProtocolException
- for protocol failures- Since:
- JavaMail 1.4.4
- See Also:
-
- "RFC 3691"
-
status
STATUS Command.- Parameters:
mbox
- the mailboxitems
- the STATUS items to request- Returns:
- STATUS results
- Throws:
ProtocolException
- for protocol failures- See Also:
-
- "RFC2060, section 6.3.10"
-
create
CREATE Command.- Parameters:
mbox
- the mailbox to create- Throws:
ProtocolException
- for protocol failures- See Also:
-
- "RFC2060, section 6.3.3"
-
delete
DELETE Command.- Parameters:
mbox
- the mailbox to delete- Throws:
ProtocolException
- for protocol failures- See Also:
-
- "RFC2060, section 6.3.4"
-
rename
RENAME Command.- Parameters:
o
- old mailbox namen
- new mailbox name- Throws:
ProtocolException
- for protocol failures- See Also:
-
- "RFC2060, section 6.3.5"
-
subscribe
SUBSCRIBE Command.- Parameters:
mbox
- the mailbox- Throws:
ProtocolException
- for protocol failures- See Also:
-
- "RFC2060, section 6.3.6"
-
unsubscribe
UNSUBSCRIBE Command.- Parameters:
mbox
- the mailbox- Throws:
ProtocolException
- for protocol failures- See Also:
-
- "RFC2060, section 6.3.7"
-
list
LIST Command.- Parameters:
ref
- reference stringpattern
- pattern to list- Returns:
- LIST results
- Throws:
ProtocolException
- for protocol failures- See Also:
-
- "RFC2060, section 6.3.8"
-
lsub
LSUB Command.- Parameters:
ref
- reference stringpattern
- pattern to list- Returns:
- LSUB results
- Throws:
ProtocolException
- for protocol failures- See Also:
-
- "RFC2060, section 6.3.9"
-
doList
Execute the specified LIST-like command (e.g., "LIST" or "LSUB"), using the reference and pattern.- Parameters:
cmd
- the list commandref
- the reference stringpat
- the pattern- Returns:
- array of ListInfo results
- Throws:
ProtocolException
- for protocol failures- Since:
- JavaMail 1.4.6
-
append
APPEND Command.- Parameters:
mbox
- the mailboxf
- the message Flagsd
- the message datedata
- the message data- Throws:
ProtocolException
- for protocol failures- See Also:
-
- "RFC2060, section 6.3.11"
-
appenduid
APPEND Command, return uid from APPENDUID response code.- Parameters:
mbox
- the mailboxf
- the message Flagsd
- the message datedata
- the message data- Returns:
- APPENDUID data
- Throws:
ProtocolException
- for protocol failures- See Also:
-
- "RFC2060, section 6.3.11"
-
appenduid
public AppendUID appenduid(String mbox, Flags f, Date d, Literal data, boolean uid) throws ProtocolException - Throws:
ProtocolException
-
check
CHECK Command.- Throws:
ProtocolException
- for protocol failures- See Also:
-
- "RFC2060, section 6.4.1"
-
close
CLOSE Command.- Throws:
ProtocolException
- for protocol failures- See Also:
-
- "RFC2060, section 6.4.2"
-
expunge
EXPUNGE Command.- Throws:
ProtocolException
- for protocol failures- See Also:
-
- "RFC2060, section 6.4.3"
-
uidexpunge
UID EXPUNGE Command.- Parameters:
set
- UIDs to expunge- Throws:
ProtocolException
- for protocol failures- See Also:
-
- "RFC4315, section 2"
-
fetchBodyStructure
Fetch the BODYSTRUCTURE of the specified message.- Parameters:
msgno
- the message number- Returns:
- the BODYSTRUCTURE item
- Throws:
ProtocolException
- for protocol failures
-
peekBody
Fetch given BODY section, without marking the message as SEEN.- Parameters:
msgno
- the message numbersection
- the body section- Returns:
- the BODY item
- Throws:
ProtocolException
- for protocol failures
-
fetchBody
Fetch given BODY section.- Parameters:
msgno
- the message numbersection
- the body section- Returns:
- the BODY item
- Throws:
ProtocolException
- for protocol failures
-
fetchBody
- Throws:
ProtocolException
-
peekBody
Partial FETCH of given BODY section, without setting SEEN flag.- Parameters:
msgno
- the message numbersection
- the body sectionstart
- starting byte countsize
- number of bytes to fetch- Returns:
- the BODY item
- Throws:
ProtocolException
- for protocol failures
-
fetchBody
Partial FETCH of given BODY section.- Parameters:
msgno
- the message numbersection
- the body sectionstart
- starting byte countsize
- number of bytes to fetch- Returns:
- the BODY item
- Throws:
ProtocolException
- for protocol failures
-
peekBody
public BODY peekBody(int msgno, String section, int start, int size, ByteArray ba) throws ProtocolException Partial FETCH of given BODY section, without setting SEEN flag.- Parameters:
msgno
- the message numbersection
- the body sectionstart
- starting byte countsize
- number of bytes to fetchba
- the buffer into which to read the response- Returns:
- the BODY item
- Throws:
ProtocolException
- for protocol failures
-
fetchBody
public BODY fetchBody(int msgno, String section, int start, int size, ByteArray ba) throws ProtocolException Partial FETCH of given BODY section.- Parameters:
msgno
- the message numbersection
- the body sectionstart
- starting byte countsize
- number of bytes to fetchba
- the buffer into which to read the response- Returns:
- the BODY item
- Throws:
ProtocolException
- for protocol failures
-
fetchBody
protected BODY fetchBody(int msgno, String section, int start, int size, boolean peek, ByteArray ba) throws ProtocolException - Throws:
ProtocolException
-
fetchSectionBody
Fetch the given body section of the given message, using the body string "body".- Parameters:
msgno
- the message numbersection
- the body sectionbody
- the body string- Returns:
- the BODY item
- Throws:
ProtocolException
- for protocol failures
-
getResponseBuffer
Return a buffer to read a response into. The buffer is provided by fetchBody and is used only once.- Overrides:
getResponseBuffer
in classProtocol
- Returns:
- the buffer to use
-
fetchRFC822
Fetch the specified RFC822 Data item. 'what' names the item to be fetched. 'what' can benull
to fetch the whole message.- Parameters:
msgno
- the message numberwhat
- the item to fetch- Returns:
- the RFC822DATA item
- Throws:
ProtocolException
- for protocol failures
-
fetchFlags
Fetch the FLAGS for the given message.- Parameters:
msgno
- the message number- Returns:
- the Flags
- Throws:
ProtocolException
- for protocol failures
-
fetchUID
Fetch the IMAP UID for the given message.- Parameters:
msgno
- the message number- Returns:
- the UID
- Throws:
ProtocolException
- for protocol failures
-
fetchMODSEQ
Fetch the IMAP MODSEQ for the given message.- Parameters:
msgno
- the message number- Returns:
- the MODSEQ
- Throws:
ProtocolException
- for protocol failures- Since:
- JavaMail 1.5.1
-
fetchSequenceNumber
Get the sequence number for the given UID. Nothing is returned; the FETCH UID response must be handled by the reponse handler, along with any possible EXPUNGE responses, to ensure that the UID is matched with the correct sequence number.- Parameters:
uid
- the UID- Throws:
ProtocolException
- for protocol failures- Since:
- JavaMail 1.5.3
-
fetchSequenceNumbers
Get the sequence numbers for UIDs ranging from start till end. Since the range may be large and sparse, an array of the UIDs actually found is returned. The caller must map these to messages after the FETCH UID responses have been handled by the reponse handler, along with any possible EXPUNGE responses, to ensure that the UIDs are matched with the correct sequence numbers.- Parameters:
start
- first UIDend
- last UID- Returns:
- array of sequence numbers
- Throws:
ProtocolException
- for protocol failures- Since:
- JavaMail 1.5.3
-
fetchSequenceNumbers
Get the sequence numbers for UIDs specified in the array. Nothing is returned. The caller must map the UIDs to messages after the FETCH UID responses have been handled by the reponse handler, along with any possible EXPUNGE responses, to ensure that the UIDs are matched with the correct sequence numbers.- Parameters:
uids
- the UIDs- Throws:
ProtocolException
- for protocol failures- Since:
- JavaMail 1.5.3
-
uidfetchChangedSince
Get the sequence numbers for messages changed since the given modseq and with UIDs ranging from start till end. Also, prefetch the flags for the returned messages.- Parameters:
start
- first UIDend
- last UIDmodseq
- the MODSEQ- Returns:
- array of sequence numbers
- Throws:
ProtocolException
- for protocol failures- Since:
- JavaMail 1.5.1
- See Also:
-
- "RFC 4551"
-
fetch
- Throws:
ProtocolException
-
fetch
- Throws:
ProtocolException
-
fetch
- Throws:
ProtocolException
-
copy
COPY command.- Parameters:
msgsets
- the messages to copymbox
- the mailbox to copy them to- Throws:
ProtocolException
- for protocol failures
-
copy
COPY command.- Parameters:
start
- start message numberend
- end message numbermbox
- the mailbox to copy them to- Throws:
ProtocolException
- for protocol failures
-
copyuid
COPY command, return uid from COPYUID response code.- Parameters:
msgsets
- the messages to copymbox
- the mailbox to copy them to- Returns:
- COPYUID response data
- Throws:
ProtocolException
- for protocol failures- See Also:
-
- "RFC 4315, section 3"
-
copyuid
COPY command, return uid from COPYUID response code.- Parameters:
start
- start message numberend
- end message numbermbox
- the mailbox to copy them to- Returns:
- COPYUID response data
- Throws:
ProtocolException
- for protocol failures- See Also:
-
- "RFC 4315, section 3"
-
move
MOVE command.- Parameters:
msgsets
- the messages to movembox
- the mailbox to move them to- Throws:
ProtocolException
- for protocol failures- Since:
- JavaMail 1.5.4
- See Also:
-
- "RFC 6851"
-
move
MOVE command.- Parameters:
start
- start message numberend
- end message numbermbox
- the mailbox to move them to- Throws:
ProtocolException
- for protocol failures- Since:
- JavaMail 1.5.4
- See Also:
-
- "RFC 6851"
-
moveuid
MOVE Command, return uid from COPYUID response code.- Parameters:
msgsets
- the messages to movembox
- the mailbox to move them to- Returns:
- COPYUID response data
- Throws:
ProtocolException
- for protocol failures- Since:
- JavaMail 1.5.4
- See Also:
-
- "RFC 6851"
- "RFC 4315, section 3"
-
moveuid
MOVE Command, return uid from COPYUID response code.- Parameters:
start
- start message numberend
- end message numbermbox
- the mailbox to move them to- Returns:
- COPYUID response data
- Throws:
ProtocolException
- for protocol failures- Since:
- JavaMail 1.5.4
- See Also:
-
- "RFC 6851"
- "RFC 4315, section 3"
-
getCopyUID
If the response contains a COPYUID response code, extract it and return a CopyUID object with the information.- Parameters:
rr
- the responses to examine- Returns:
- the COPYUID response code data, or null if not found
- Since:
- JavaMail 1.5.4
-
storeFlags
- Throws:
ProtocolException
-
storeFlags
- Throws:
ProtocolException
-
storeFlags
Set the specified flags on this message.- Parameters:
msg
- the message numberflags
- the flagsset
- true to set, false to clear- Throws:
ProtocolException
- for protocol failures
-
createFlagList
Creates an IMAP flag_list from the given Flags object.- Parameters:
flags
- the flags- Returns:
- the IMAP flag_list
- Since:
- JavaMail 1.5.4
-
search
public int[] search(MessageSet[] msgsets, SearchTerm term) throws ProtocolException, SearchException Issue the given search criterion on the specified message sets. Returns array of matching sequence numbers. An empty array is returned if no matches are found.- Parameters:
msgsets
- array of MessageSetsterm
- SearchTerm- Returns:
- array of matching sequence numbers.
- Throws:
ProtocolException
- for protocol failuresSearchException
- for search failures
-
search
Issue the given search criterion on all messages in this folder. Returns array of matching sequence numbers. An empty array is returned if no matches are found.- Parameters:
term
- SearchTerm- Returns:
- array of matching sequence numbers.
- Throws:
ProtocolException
- for protocol failuresSearchException
- for search failures
-
getSearchSequence
Get the SearchSequence object. The SearchSequence object instance is saved in the searchSequence field. Subclasses of IMAPProtocol may override this method to return a subclass of SearchSequence, in order to add support for product-specific search terms.- Returns:
- the SearchSequence
- Since:
- JavaMail 1.4.6
-
sort
Sort messages in the folder according to the specified sort criteria. If the search term is not null, limit the sort to only the messages that match the search term. Returns an array of sorted sequence numbers. An empty array is returned if no matches are found.- Parameters:
term
- sort criteriasterm
- SearchTerm- Returns:
- array of matching sequence numbers.
- Throws:
ProtocolException
- for protocol failuresSearchException
- for search failures- Since:
- JavaMail 1.4.4
- See Also:
-
- "RFC 5256"
-
namespace
NAMESPACE Command.- Returns:
- the namespaces
- Throws:
ProtocolException
- for protocol failures- See Also:
-
- "RFC2342"
-
getQuotaRoot
GETQUOTAROOT Command. Returns an array of Quota objects, representing the quotas for this mailbox and, indirectly, the quotaroots for this mailbox.- Parameters:
mbox
- the mailbox- Returns:
- array of Quota objects
- Throws:
ProtocolException
- for protocol failures- See Also:
-
- "RFC2087"
-
getQuota
GETQUOTA Command. Returns an array of Quota objects, representing the quotas for this quotaroot.- Parameters:
root
- the quotaroot- Returns:
- the quotas
- Throws:
ProtocolException
- for protocol failures- See Also:
-
- "RFC2087"
-
setQuota
SETQUOTA Command. Set the indicated quota on the corresponding quotaroot.- Parameters:
quota
- the quota to set- Throws:
ProtocolException
- for protocol failures- See Also:
-
- "RFC2087"
-
setACL
SETACL Command.- Parameters:
mbox
- the mailboxmodifier
- the ACL modifieracl
- the ACL- Throws:
ProtocolException
- for protocol failures- See Also:
-
- "RFC2086"
-
deleteACL
DELETEACL Command.- Parameters:
mbox
- the mailboxuser
- the user- Throws:
ProtocolException
- for protocol failures- See Also:
-
- "RFC2086"
-
getACL
GETACL Command.- Parameters:
mbox
- the mailbox- Returns:
- the ACL array
- Throws:
ProtocolException
- for protocol failures- See Also:
-
- "RFC2086"
-
listRights
LISTRIGHTS Command.- Parameters:
mbox
- the mailboxuser
- the user rights to return- Returns:
- the rights array
- Throws:
ProtocolException
- for protocol failures- See Also:
-
- "RFC2086"
-
myRights
MYRIGHTS Command.- Parameters:
mbox
- the mailbox- Returns:
- the rights
- Throws:
ProtocolException
- for protocol failures- See Also:
-
- "RFC2086"
-
idleStart
IDLE Command.If the server supports the IDLE command extension, the IDLE command is issued and this method blocks until a response has been received. Once the first response has been received, the IDLE command is terminated and all responses are collected and handled and this method returns.
Note that while this method is blocked waiting for a response, no other threads may issue any commands to the server that would use this same connection.
- Throws:
ProtocolException
- for protocol failures- Since:
- JavaMail 1.4.1
- See Also:
-
- "RFC2177"
-
readIdleResponse
While an IDLE command is in progress, read a response sent from the server. The response is read with no locks held so that when the read blocks waiting for the response from the server it's not holding locks that would prevent other threads from interrupting the IDLE command.- Returns:
- the response
- Since:
- JavaMail 1.4.1
-
processIdleResponse
Process a response returned by readIdleResponse(). This method will be called with appropriate locks held so that the processing of the response is safe.- Parameters:
r
- the response- Returns:
- true if IDLE is done
- Throws:
ProtocolException
- for protocol failures- Since:
- JavaMail 1.4.1
-
idleAbort
public void idleAbort()Abort an IDLE command. While one thread is blocked in readIdleResponse(), another thread will use this method to abort the IDLE command, which will cause the server to send the closing tag for the IDLE command, which readIdleResponse() and processIdleResponse() will see and terminate the IDLE state.- Since:
- JavaMail 1.4.1
-
id
ID Command.- Parameters:
clientParams
- map of names and values- Returns:
- map of names and values from server
- Throws:
ProtocolException
- for protocol failures- Since:
- JavaMail 1.5.1
- See Also:
-
- "RFC 2971"
-
id(Map<String,String>)