MailClient class

Highlevel online API to access mail.

Constructors

MailClient(MailAccount account, {bool isLogEnabled = false, int? downloadSizeLimit, EventBus? eventBus, String? logName, Duration? defaultWriteTimeout = const Duration(seconds: 2), Duration? defaultResponseTimeout = const Duration(seconds: 5), bool onBadCertificate(X509Certificate)?, Id? clientId, Future<OauthToken?> refresh(MailClient client, OauthToken expiredToken)?, Future onConfigChanged(MailAccount account)?})
Creates a new highlevel online mail client for the given account.

Properties

account MailAccount
The mail account associated used by this client
no setter
clientId Id?
The ID of the client app using this MailClient.
final
defaultResponseTimeout Duration?
The default timeout for server responses, currently only used on IMAP for selected commands.
final
defaultWriteTimeout Duration?
The default timeout for write operations
final
eventBus → EventBus
event bus for firing and listening to events
no setter
hashCode int
The hash code for this object.
no setterinherited
isConnected bool
Checks if this mail client is connected
no setter
lowLevelIncomingMailClient → ClientBase
Retrieves the low level mail client for reading mails
no setter
lowLevelIncomingMailClientType ServerType
Retrieves the type of the low level incoming client.
no setter
lowLevelOutgoingMailClient → ClientBase
Retrieves the low level mail client for sending mails
no setter
lowLevelOutgoingMailClientType ServerType
Retrieves the type pof the low level mail client.
no setter
mailboxes List<Mailbox>?
Retrieves the previously caches mailboxes
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
selectedMailbox Mailbox?
Retrieves the currently selected mailbox, if any.
no setter
serverId Id?
The ID of the IMAP server this mail client is connected to.
no setter
supportsMailboxes bool
Checks if this mail client supports different mailboxes
no setter
supportsThreading bool
Checks if the connected service supports threading
no setter

Methods

addEventFilter(MailEventFilter filter) → void
Adds the specified mail event filter.
appendMessage(MimeMessage message, Mailbox targetMailbox, {List<String>? flags}) Future<UidResponseCode?>
Appends the message to the targetMailbox.
appendMessageToFlag(MimeMessage message, MailboxFlag targetMailboxFlag, {List<String>? flags}) Future<UidResponseCode?>
Appends the message to the mailbox with the targetMailboxFlag.
buildMimeMessageWithRecommendedTextEncoding(MessageBuilder messageBuilder) Future<MimeMessage?>
Builds the mime message from the given messageBuilder with the recommended text encodings.
connect({Duration timeout = const Duration(seconds: 20)}) Future<void>
Connects and authenticates with the specified incoming mail server.
createMailbox(String mailboxName, {Mailbox? parentMailbox}) Future<Mailbox>
Creates a new mailbox with the given mailboxName.
deleteAllMessages(Mailbox mailbox, {bool expunge = false}) Future<DeleteResult>
Deletes all messages from the specified mailbox.
deleteMailbox(Mailbox mailbox) Future<void>
Deletes the specified mailbox
deleteMessage(MimeMessage message, {bool expunge = false}) Future<DeleteResult>
Deletes the given message.
deleteMessages(MessageSequence sequence, {bool expunge = false, List<MimeMessage>? messages}) Future<DeleteResult>
Deletes the given message sequence.
disconnect() Future<void>
Disconnects from the mail service.
fetchMessageContents(MimeMessage message, {int? maxSize, bool markAsSeen = false, List<MediaToptype>? includedInlineTypes, Duration? responseTimeout}) Future<MimeMessage>
Fetches the contents of the specified message.
fetchMessagePart(MimeMessage message, String fetchId, {Duration? responseTimeout}) Future<MimePart>
Fetches the part with the specified fetchId of the specified message.
fetchMessages({Mailbox? mailbox, int count = 20, int page = 1, FetchPreference fetchPreference = FetchPreference.fullWhenWithinSize}) Future<List<MimeMessage>>
Loads the specified page of messages starting at the latest message and going down count messages.
fetchMessageSequence(MessageSequence sequence, {Mailbox? mailbox, FetchPreference fetchPreference = FetchPreference.fullWhenWithinSize, bool markAsSeen = false}) Future<List<MimeMessage>>
Loads the specified sequence of messages.
fetchMessagesNextPage(PagedMessageSequence pagedSequence, {Mailbox? mailbox, FetchPreference fetchPreference = FetchPreference.fullWhenWithinSize, bool markAsSeen = false}) Future<List<MimeMessage>>
Loads the next page of messages in the given pagedSequence.
fetchNextPage(PagedMessageResult pagedResult) Future<List<MimeMessage>>
Retrieves the next page of messages for the specified pagedResult.
fetchThreadData({required DateTime since, Mailbox? mailbox, bool setThreadSequences = false}) Future<ThreadDataResult>
Retrieves thread information starting at since.
fetchThreads({required DateTime since, Mailbox? mailbox, ThreadPreference threadPreference = ThreadPreference.latest, FetchPreference fetchPreference = FetchPreference.envelope, int pageSize = 30, Duration? responseTimeout}) Future<ThreadResult>
Retrieves the threads starting at since.
fetchThreadsNextPage(ThreadResult threadResult) Future<List<MimeMessage>>
Retrieves the next page for the given threadResult and returns the loaded messages.
flagMessage(MimeMessage message, {bool? isSeen, bool? isFlagged, bool? isAnswered, bool? isForwarded, bool? isDeleted, bool? isMdnSent, bool? isReadReceiptSent}) Future<void>
Flags the message with the specified flags.
getMailbox(MailboxFlag flag, [List<Mailbox>? boxes]) Mailbox?
Retrieves the mailbox with the specified flag from the provided boxes.
isPolling() bool
Checks if this mail client is currently polling.
junkMessage(MimeMessage message) Future<MoveResult>
Moves the specified message to the junk folder
junkMessages(MessageSequence sequence, {List<MimeMessage>? messages}) Future<MoveResult>
Moves the specified message sequence to the junk folder
listMailboxes({List<MailboxFlag>? order}) Future<List<Mailbox>>
Lists all mailboxes/folders of the incoming mail server.
listMailboxesAsTree({bool createIntermediate = true, List<MailboxFlag> order = defaultMailboxOrder}) Future<Tree<Mailbox?>>
Lists all mailboxes/folders of the incoming mail server as a tree in the specified order.
markAnswered(MessageSequence sequence, {int? unchangedSinceModSequence}) Future<void>
Mark the messages from the specified sequence as answered.
markDeleted(MessageSequence sequence, {int? unchangedSinceModSequence}) Future<void>
Mark the messages from the specified sequence as deleted.
markFlagged(MessageSequence sequence, {int? unchangedSinceModSequence}) Future<void>
Mark the messages from the specified sequence as flagged.
markForwarded(MessageSequence sequence, {bool? silent, int? unchangedSinceModSequence}) Future<void>
Mark from the specified sequence as forwarded.
markSeen(MessageSequence sequence, {int? unchangedSinceModSequence}) Future<void>
Mark the messages from the specified sequence as seen/read.
markUnanswered(MessageSequence sequence, {int? unchangedSinceModSequence}) Future<void>
Mark the messages from the specified sequence as not answered.
markUndeleted(MessageSequence sequence, {int? unchangedSinceModSequence}) Future<void>
Mark the messages from the specified sequence as not deleted.
markUnflagged(MessageSequence sequence, {int? unchangedSinceModSequence}) Future<void>
Mark the messages from the specified sequence as unflagged.
markUnforwarded(MessageSequence sequence, {int? unchangedSinceModSequence}) Future<void>
Mark the messages from the specified sequence as not forwarded.
markUnseen(MessageSequence sequence, {int? unchangedSinceModSequence}) Future<void>
Mark the messages from the specified sequence as unseen/unread.
moveMessage(MimeMessage message, Mailbox target) Future<MoveResult>
Moves the specified message to the given target folder
moveMessages(MessageSequence sequence, Mailbox target, {List<MimeMessage>? messages}) Future<MoveResult>
Moves the specified message sequence to the given target folder
moveMessagesToFlag(MessageSequence sequence, MailboxFlag flag, {List<MimeMessage>? messages}) Future<MoveResult>
Moves the specified message sequence to the folder flagged with the specified mailbox flag.
moveMessagesToInbox(MessageSequence sequence, {List<MimeMessage>? messages}) Future<MoveResult>
Moves the specified message sequence to the inbox folder
moveMessageToFlag(MimeMessage message, MailboxFlag flag) Future<MoveResult>
Moves the specified message to the folder flagged with the specified mailbox flag.
moveMessageToInbox(MimeMessage message) Future<MoveResult>
Moves the specified message to the inbox folder
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
reconnect() Future<void>
Enforces to reconnect with the incoming service.
removeEventFilter(MailEventFilter filter) → void
Removes the specified mail event filter.
resume({bool startPollingWhenError = true}) Future<void>
Resumes the mail client after a some inactivity.
saveDraftMessage(MimeMessage message, {Mailbox? draftsMailbox}) Future<UidResponseCode?>
Appends the message to the drafts mailbox with the \Draft and \Seen message flags.
searchMessages(MailSearch search) Future<MailSearchResult>
Searches the messages with the criteria defined in search.
searchMessagesNextPage(MailSearchResult searchResult) Future<List<MimeMessage>>
Retrieves the next page of messages for the specified searchResult.
selectInbox({bool enableCondStore = false, QResyncParameters? qresync}) Future<Mailbox>
Shortcut to select the INBOX.
selectMailbox(Mailbox mailbox, {bool enableCondStore = false, QResyncParameters? qresync}) Future<Mailbox>
Selects the specified mailbox/folder.
selectMailboxByFlag(MailboxFlag flag, {bool enableCondStore = false, QResyncParameters? qresync}) Future<Mailbox>
Selects the mailbox/folder with the specified flag.
selectMailboxByPath(String path, {bool enableCondStore = false, QResyncParameters? qresync}) Future<Mailbox>
Selects the mailbox/folder with the specified path.
sendMessage(MimeMessage message, {MailAddress? from, bool appendToSent = true, Mailbox? sentMailbox, bool use8BitEncoding = false, List<MailAddress>? recipients}) Future<void>
Sends the specified message.
sendMessageBuilder(MessageBuilder messageBuilder, {MailAddress? from, bool appendToSent = true, Mailbox? sentMailbox, List<MailAddress>? recipients}) Future<void>
Sends the message defined with the specified messageBuilder with the recommended text encoding.
sortMailboxes(List<MailboxFlag> order, List<Mailbox> mailboxes, {bool keepRemaining = true, bool sortRemainingAlphabetically = true}) List<Mailbox>
Retrieves the mailbox with the specified order from the provided mailboxes. The underlying mailboxes are not changed.
startPolling([Duration duration = defaultPollingDuration]) Future<void>
Starts listening for new incoming messages.
stopPolling() Future<void>
Stops listening for new messages.
stopPollingIfNeeded() Future<void>
Stops listening for new messages if this client is currently polling.
store(MessageSequence sequence, List<String> flags, {StoreAction action = StoreAction.add, int? unchangedSinceModSequence}) Future<void>
Stores the specified message flags for the given message sequence.
supports8BitEncoding() Future<bool>
Checks if the mail provider supports 8 bit encoding for new messages.
supportsFlagging() bool
Determines if message flags such as \Seen can be stored.
toString() String
A string representation of this object.
inherited
undoDeleteMessages(DeleteResult deleteResult) Future<DeleteResult>
Reverts the previous deleteResult
undoMoveMessages(MoveResult moveResult) Future<MoveResult>
Reverts the previous move operation, if possible.

Operators

operator ==(Object other) bool
The equality operator.
inherited

Constants

defaultMailboxOrder → const List<MailboxFlag>
Default ordering for mailboxes
defaultPollingDuration → const Duration
Default polling duration (every 2 minutes)