ImapClient class
Low-level IMAP library.
Compliant to IMAP4rev1 standard RFC 3501. Also compare recommendations at RFC 2683
Constructors
- ImapClient({EventBus? bus, bool isLogEnabled = false, String? logName, Duration? defaultWriteTimeout, Duration? defaultResponseTimeout, bool onBadCertificate(X509Certificate)?})
- Creates a new ImapClient instance.
Properties
- connectionInfo ↔ ConnectionInfo
-
Information about the connection
getter/setter pairinherited
- defaultResponseTimeout → Duration?
-
The default timeout for getting a response
final
- defaultWriteTimeout → Duration?
-
The default timeout for sending a command
final
- eventBus → EventBus
-
Allows to listens for events
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- isConnected → bool
-
Ist the client currently connected?
no setterinherited
- isLogEnabled ↔ bool
-
true
when the log is enabledgetter/setter pairinherited - isLoggedIn ↔ bool
-
true
after the user has authenticatedgetter/setter pairinherited - isSocketClosingExpected ↔ bool
-
true
when it is expected that the socket is closedgetter/setter pairinherited - logName ↔ String?
-
The name shown in log entries to differentiate this server
getter/setter pairinherited
- onBadCertificate → (bool Function(X509Certificate)?)
-
Handles unverifiable certificates.
finalinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- serverInfo → ImapServerInfo
-
Information about the IMAP service
no setter
Methods
-
appendMessage(
MimeMessage message, {List< String> ? flags, Mailbox? targetMailbox, String? targetMailboxPath, Duration? responseTimeout}) → Future<GenericImapResult> -
Appends the specified MIME
message
. -
appendMessageText(
String messageText, {List< String> ? flags, Mailbox? targetMailbox, String? targetMailboxPath, Duration? responseTimeout}) → Future<GenericImapResult> -
Appends the specified MIME
messageText
. -
applyStashedTasks(
) → Future< void> - Applies the stashed tasks
-
authenticateWithOAuth2(
String user, String accessToken) → Future< List< Capability> > -
Logs in the user with the given
user
andaccessToken
via Oauth 2.0. -
authenticateWithOAuthBearer(
String user, String accessToken, {String? host, int? port}) → Future< List< Capability> > -
Logs in the user with the given
user
andaccessToken
via Oauth Bearer mechanism. -
capability(
) → Future< List< Capability> > - Checks the capabilities of this server directly
-
check(
) → Future< Mailbox?> - Trigger a check operation for the server's housekeeping.
-
closeConnection(
) → Future -
Closes the connection. Deprecated: use
disconnect()
instead. -
closeMailbox(
) → Future< Mailbox?> - Closes the currently selected mailbox and triggers an implicit EXPUNGE.
-
connect(
Socket socket, {ConnectionInfo? connectionInformation}) → void -
Starts to listen on the given
socket
.inherited -
connectToServer(
String host, int port, {bool isSecure = true, Duration timeout = const Duration(seconds: 20)}) → Future< ConnectionInfo> -
Connects to the specified server.
inherited
-
copy(
MessageSequence sequence, {Mailbox? targetMailbox, String? targetMailboxPath}) → Future< GenericImapResult> -
Copies the specified message(s) from the specified
sequence
from the currently selected mailbox to the target mailbox. -
createClientError(
String message) → Object - Subclasses need to be able to create client specific exceptions
-
createMailbox(
String path) → Future< Mailbox> -
Creates a new mailbox with the specified
path
-
deleteMailbox(
Mailbox box) → Future< Mailbox> - Removes the specified mailbox
-
disconnect(
) → Future< void> -
Disconnects from the service
inherited
-
enable(
List< String> capabilities) → Future<List< Capability> > -
Enables the specified
capabilities
. -
examineMailbox(
Mailbox box, {bool enableCondStore = false, QResyncParameters? qresync}) → Future< Mailbox> -
Examines the
box
without selecting it. -
expunge(
) → Future< Mailbox?> - Expunges (deletes) any messages that are marked as deleted.
-
fetchMessage(
int messageSequenceId, String fetchContentDefinition, {Duration? responseTimeout}) → Future< FetchImapResult> - Fetches a single message by the given definition.
-
fetchMessages(
MessageSequence sequence, String? fetchContentDefinition, {int? changedSinceModSequence, Duration? responseTimeout}) → Future< FetchImapResult> - Fetches messages by the given definition.
-
fetchMessagesByCriteria(
String fetchIdsAndCriteria, {Duration? responseTimeout}) → Future< FetchImapResult> - Fetches messages by the specified criteria.
-
fetchRecentMessages(
{int messageCount = 30, String criteria = '(FLAGS BODY[])', Duration? responseTimeout}) → Future< FetchImapResult> - Fetches the specified number of recent messages by the specified criteria.
-
getMetaData(
String entry, {String? mailboxName, int? maxSize, MetaDataDepth? depth}) → Future< List< MetaDataEntry> > - Retrieves the specified meta data entry.
-
getQuota(
{String quotaRoot = '""'}) → Future< QuotaResult> -
Retrieves the quota for the user/
quotaRoot
. -
getQuotaRoot(
{String mailboxName = '""'}) → Future< QuotaRootResult> -
Retrieves the quota root for the specified
mailboxName
which defaults to the root""
. -
id(
{Id? clientId}) → Future< Id?> -
Reports the optional
clientId
to the server and returns the server ID. -
idleDone(
) → Future - Stops the IDLE mode.
-
idleStart(
) → Future< void> - Switches to IDLE mode.
-
listMailboxes(
{String path = '""', bool recursive = false, List< String> ? mailboxPatterns, List<String> ? selectionOptions, List<ReturnOption> ? returnOptions}) → Future<List< Mailbox> > -
Lists all mailboxes in the given
path
. -
listMailboxesByReferenceAndName(
String referenceName, String mailboxName, [List< String> ? mailboxPatterns, List<String> ? selectionOptions, List<ReturnOption> ? returnOptions]) → Future<List< Mailbox> > -
Lists all mailboxes in the path
referenceName
that match the givenmailboxName
that can contain wildcards. -
listSubscribedMailboxes(
{String path = '""', bool recursive = false}) → Future< List< Mailbox> > - Lists all subscribed mailboxes
-
log(
dynamic logObject, {bool isClient = true, String? initial}) → void -
Logs the data
inherited
-
logApp(
dynamic logObject) → void -
Logs the data from the app-side
inherited
-
logClient(
dynamic logObject) → void -
Logs the data from the client-side
inherited
-
login(
String name, String password) → Future< List< Capability> > -
Logs in the user with the given
name
andpassword
. -
logout(
) → Future - Logs the current user out.
-
logServer(
dynamic logObject) → void -
Logs the data from the server-side
inherited
-
markAnswered(
MessageSequence sequence, {bool? silent, int? unchangedSinceModSequence}) → Future< StoreImapResult> -
Mark the messages from the specified
sequence
as answered. -
markDeleted(
MessageSequence sequence, {bool? silent, int? unchangedSinceModSequence}) → Future< StoreImapResult> -
Mark the messages from the specified
sequence
as deleted. -
markFlagged(
MessageSequence sequence, {bool? silent, int? unchangedSinceModSequence}) → Future< StoreImapResult> -
Mark the messages from the specified
sequence
as flagged. -
markForwarded(
MessageSequence sequence, {bool? silent, int? unchangedSinceModSequence}) → Future< StoreImapResult> -
Mark the messages from the specified
sequence
as forwarded. -
markSeen(
MessageSequence sequence, {bool? silent, int? unchangedSinceModSequence}) → Future< StoreImapResult> -
Mark the messages from the specified
sequence
as seen/read. -
markUnanswered(
MessageSequence sequence, {bool? silent, int? unchangedSinceModSequence}) → Future< StoreImapResult> -
Mark the messages from the specified
sequence
as not answered. -
markUndeleted(
MessageSequence sequence, {bool? silent, int? unchangedSinceModSequence}) → Future< StoreImapResult> -
Mark the messages from the specified
sequence
as not deleted. -
markUnflagged(
MessageSequence sequence, {bool? silent, int? unchangedSinceModSequence}) → Future< StoreImapResult> -
Mark the messages from the specified
sequence
as unflagged. -
markUnforwarded(
MessageSequence sequence, {bool? silent, int? unchangedSinceModSequence}) → Future< StoreImapResult> -
Mark the messages from the specified
sequence
as not forwarded. -
markUnseen(
MessageSequence sequence, {bool? silent, int? unchangedSinceModSequence}) → Future< StoreImapResult> -
Mark the messages from the specified
sequence
as unseen/unread. -
move(
MessageSequence sequence, {Mailbox? targetMailbox, String? targetMailboxPath}) → Future< GenericImapResult> -
Moves the specified message(s) from the specified
sequence
from the currently selected mailbox to the target mailbox. -
nextId(
) → String - Retrieves the next session-unique command ID
-
noop(
) → Future< Mailbox?> - Trigger a noop (no operation).
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onCommandResult(
ImapResponse imapResponse) → void - Processes the command result response from the server.
-
onConnectionDone(
) → void -
Informs about a closed connection
inherited
-
onConnectionError(
dynamic error) → void - Is called when the connection encountered an error
-
onConnectionEstablished(
ConnectionInfo connectionInfo, String serverGreeting) → FutureOr< void> - Is called after the initial connection has been established
-
onContinuationResponse(
ImapResponse imapResponse) → Future - Handles an continuation response from the server
-
onDataReceived(
Uint8List data) → void - Is called when data is received
-
onServerResponse(
ImapResponse imapResponse) → void -
Handles the specified
imapResponse
from the server. -
onUntaggedResponse(
ImapResponse imapResponse) → void - Handles an untagged response from the server
-
queueTask(
CommandTask task) → void -
Queues the given
task
. -
renameMailbox(
Mailbox box, String newName) → Future< Mailbox> - Renames the specified mailbox
-
searchMessages(
{String searchCriteria = 'UNSEEN', List< ReturnOption> ? returnOptions, Duration? responseTimeout}) → Future<SearchImapResult> -
Searches messages by the given
searchCriteria
like'UNSEEN'
or'RECENT'
or'FROM sender@domain.com'
. -
searchMessagesWithQuery(
SearchQueryBuilder query, {Duration? responseTimeout}) → Future< SearchImapResult> -
Searches messages with the given
query
. -
selectInbox(
{bool enableCondStore = false, QResyncParameters? qresync}) → Future< Mailbox> - Selects the inbox.
-
selectMailbox(
Mailbox box, {bool enableCondStore = false, QResyncParameters? qresync}) → Future< Mailbox> - Selects the specified mailbox.
-
selectMailboxByPath(
String path, {bool enableCondStore = false, QResyncParameters? qresync}) → Future< Mailbox> - Selects the specified mailbox.
-
sendCommand<
T> (Command command, ResponseParser< T> parser, {bool returnCompleter = true}) → Future<T> -
Queues the specified
command
for sending to the server. -
sendCommandTask<
T> (CommandTask< T> task, {bool returnCompleter = true}) → Future<T> -
Queues the given
task
for sending to the server. -
setMetaData(
MetaDataEntry entry) → Future< Mailbox?> -
Saves the specified meta data
entry
. -
setMetaDataEntries(
List< MetaDataEntry> entries) → Future<Mailbox?> -
Saves the given meta data
entries
. -
setQuota(
{required Map< String, int> resourceLimits, String quotaRoot = '""'}) → Future<QuotaResult> -
Sets the quota
resourceLimits
for the the user /quotaRoot
. -
sortMessages(
String sortCriteria, [String searchCriteria = 'ALL', String charset = 'UTF-8', List< ReturnOption> ? returnOptions]) → Future<SortImapResult> - Sorts messages by the given criteria.
-
startTls(
) → Future< GenericImapResult> - Upgrades the current insure connection to SSL.
-
stashQueuedTasks(
) → void - Remembers the queued tasks until applyStashedTasks is called.
-
statusMailbox(
Mailbox box, List< StatusFlags> flags) → Future<Mailbox> -
Checks the status of the currently not selected
box
. -
store(
MessageSequence sequence, List< String> flags, {StoreAction? action, bool? silent, int? unchangedSinceModSequence}) → Future<StoreImapResult> -
Updates the
flags
of the message(s) from the specifiedsequence
in the currently selected mailbox. -
subscribeMailbox(
Mailbox box) → Future< Mailbox> - Subscribes the specified mailbox.
-
threadMessages(
{required DateTime since, String method = 'ORDEREDSUBJECT', String charset = 'UTF-8', bool threadUids = false, Duration? responseTimeout}) → Future< SequenceNode> -
Requests the IDs of message threads starting on
since
using the givenmethod
(defaults toORDEREDSUBJECT
) andcharset
(defaults toUTF-8
). -
toString(
) → String -
A string representation of this object.
inherited
-
uidCopy(
MessageSequence sequence, {Mailbox? targetMailbox, String? targetMailboxPath}) → Future< GenericImapResult> -
Copies the specified message(s) from the specified
sequence
from the currently selected mailbox to the target mailbox. -
uidExpunge(
MessageSequence sequence) → Future< Mailbox?> -
Expunges (deletes) any messages that are in the specified
sequence
AND marked as deleted. -
uidFetchMessage(
int messageUid, String fetchContentDefinition, {Duration? responseTimeout}) → Future< FetchImapResult> -
Fetches a single messages identified by the
messageUid
-
uidFetchMessages(
MessageSequence sequence, String? fetchContentDefinition, {int? changedSinceModSequence, Duration? responseTimeout}) → Future< FetchImapResult> - Fetches messages by the given definition.
-
uidFetchMessagesByCriteria(
String fetchIdsAndCriteria, {Duration? responseTimeout}) → Future< FetchImapResult> - Fetches messages by the specified criteria.
-
uidMarkAnswered(
MessageSequence sequence, {bool? silent, int? unchangedSinceModSequence}) → Future< StoreImapResult> -
Mark the messages from the specified
sequence
as answered. -
uidMarkDeleted(
MessageSequence sequence, {bool? silent, int? unchangedSinceModSequence}) → Future< StoreImapResult> -
Mark the messages from the specified
sequence
as deleted. -
uidMarkFlagged(
MessageSequence sequence, {bool? silent, int? unchangedSinceModSequence}) → Future< StoreImapResult> -
Mark the messages from the specified
sequence
as flagged. -
uidMarkForwarded(
MessageSequence sequence, {bool? silent, int? unchangedSinceModSequence}) → Future< StoreImapResult> -
Mark the messages from the specified
sequence
as forwarded. -
uidMarkSeen(
MessageSequence sequence, {bool? silent, int? unchangedSinceModSequence}) → Future< StoreImapResult> -
Mark the messages from the specified
sequence
as seen/read. -
uidMarkUnanswered(
MessageSequence sequence, {bool? silent, int? unchangedSinceModSequence}) → Future< StoreImapResult> -
Mark the messages from the specified
sequence
as not answered. -
uidMarkUndeleted(
MessageSequence sequence, {bool? silent, int? unchangedSinceModSequence}) → Future< StoreImapResult> -
Mark the messages from the specified
sequence
as not deleted. -
uidMarkUnflagged(
MessageSequence sequence, {bool? silent, int? unchangedSinceModSequence}) → Future< StoreImapResult> -
Mark the messages from the specified
sequence
as unflagged. -
uidMarkUnforwarded(
MessageSequence sequence, {bool? silent, int? unchangedSinceModSequence}) → Future< StoreImapResult> -
Mark the messages from the specified
sequence
as not forwarded. -
uidMarkUnseen(
MessageSequence sequence, {bool? silent, int? unchangedSinceModSequence}) → Future< StoreImapResult> -
Mark the messages from the specified
sequence
as unseen/unread. -
uidMove(
MessageSequence sequence, {Mailbox? targetMailbox, String? targetMailboxPath}) → Future< GenericImapResult> -
Copies the specified message(s) from the specified
sequence
from the currently selected mailbox to the target mailbox. -
uidSearchMessages(
{String searchCriteria = 'UNSEEN', List< ReturnOption> ? returnOptions, Duration? responseTimeout}) → Future<SearchImapResult> -
Searches messages by the given
searchCriteria
like'UNSEEN'
or'RECENT'
or'FROM sender@domain.com'
. -
uidSearchMessagesWithQuery(
SearchQueryBuilder query, {List< ReturnOption> ? returnOptions, Duration? responseTimeout}) → Future<SearchImapResult> -
Searches messages with the given
query
. -
uidSortMessages(
String sortCriteria, [String searchCriteria = 'ALL', String charset = 'UTF-8', List< ReturnOption> ? returnOptions]) → Future<SortImapResult> - Sorts messages by the given criteria
-
uidStore(
MessageSequence sequence, List< String> flags, {StoreAction? action, bool? silent, int? unchangedSinceModSequence}) → Future<StoreImapResult> -
Updates the
flags
of the message(s) from the specifiedsequence
in the currently selected mailbox. -
uidThreadMessages(
{required DateTime since, String method = 'ORDEREDSUBJECT', String charset = 'UTF-8', Duration? responseTimeout}) → Future< SequenceNode> -
Requests the UIDs of message threads starting on
since
using the givenmethod
(defaults toORDEREDSUBJECT
) andcharset
(defaults toUTF-8
). -
unselectMailbox(
) → Future< void> - Closes the currently selected mailbox without triggering the expunge events.
-
unsubscribeMailbox(
Mailbox box) → Future< Mailbox> - Unsubscribes the specified mailbox.
-
upgradeToSslSocket(
) → Future< void> -
Upgrades the current connection to a secure socket
inherited
-
writeData(
List< int> data, [dynamic logObject]) → Future -
Writes the specified
data
.inherited -
writeText(
String text, [dynamic logObject, Duration? timeout]) → Future -
Writes the specified
text
.inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited