1.1.0 • Published 3 years ago

cordova-plugin-imap v1.1.0

Weekly downloads
4
License
ISC
Repository
github
Last release
3 years ago

Cordova IMAP plugin

This plugin will enable a Cordova application to use the IMAP (Internet Message Access Protocol) features. The plugin offers support for Android and iOS. To enable the IMAP features on Android, this plugin uses the framework Java Mail API and for iOS, it uses the MailCore 2 library.

Supported Platforms

  • Android
  • iOS

Installation

Install the plugin by running:

cordova plugin add cordova-plugin-imap

API

  • connect(config, success, error) - (Connection) - Tries to connect and authenticate with the IMAP server.
  • disconnect(success, error) - (boolean) - Closes the connection with the server.
  • isConnected(success, error) - (boolean) - Checks the current state of the connection.
  • listMailFolders(pattern, success, error) - (string[]) - Lists the name of all the mail folders in the mailbox.
  • getMessageCountByFolderName(folderName, success, error) - (number) - Gets the count of the messages in the folder.
  • searchMessagesByDatePeriod(folderName, dateInMilliseconds, comparison : enum, success, error) - (number[]) - Returns the messages' consecutive numbers.
  • listMessagesHeadersByConsecutiveNumber(folderName, start, end, success, error) - (MessageHeaders[]) - Returns messages' headers data.
  • listMessagesHeadersByDate(folderName, dateInMilliseconds, comparison : enum, success, error) - (MessageHeaders[]) - Returns messages' headers data.
  • getFullMessageData(folderName, messageNumber, success, error) - (Message) - Returns the full message data inclucing its attachments.
  • getFullMessageDataOnNewSession(config, folderName, messageNumber, success, error) - (Message) - Returns the full message data inclucing its attachments.
  • copyToFolder (sourceFolder, destinationFolder, messageNums, success, error) - (boolean) - Copy messages to a desired folder
  • setFlag (folderName, messageNums, flag : enum, status, success, error) - (ModificationResult) - Sets a flag on a message. This method can also be used for deleting messages.

Data types

Config

ParamTypeDescription
hoststringHostname or IP address of the IMAP service.
portnumberOptional. Port of the IMAP server to connect. Default set to: 993
connectionType ConnectionTypeiOS ONLY. Optional. Encryption type to use. Default set to: TLS/SSL
userstringUsername or email address for authentication.
passwordstringPassword for authentication.

ConnectionType enum

NameTypeDescription
ClearMCOConnectionTypeClear-text connection for the protocol.
StartTLSMCOConnectionTypeStart with clear-text connection at the beginning, then switch to encrypted connection using TLS/SSL
TLS/SSLMCOConnectionTypeEncrypted connection using TLS/SSL

Connection

ParamTypeDescription
statusbooleanConnection status.
connectionstringOptional. Connection String result, returned when the connection is established successfully.
exceptionstringOptional. Exception details, in case an error occurs.

MessageHeaders

ParamTypeDescription
messageNumbernumberMessage consecutive number.
folderstringThe name of the message's folder.
fromArray<Address>Sender's data.
toRecipientsArray<Address>TO recipients data.
ccRecipientsArray<Address>CC recipients data.
bccRecipientsArray<Address>BCC recipients data.
receivedDatestringThe date when the message was received.
subjectstringMessage's subject.
flagsArray<string>Message's active flags

Message

ParamTypeDescription
messageNumbernumberMessage consecutive number.
folderstringThe name of the message's folder.
fromArray<Address>Sender's data.
allRecipientsArray<Address>All recipients data.
toRecipientsArray<Address>TO recipients data.
ccRecipientsArray<Address>CC recipients data.
bccRecipientsArray<Address>BCC recipients data.
replyToArray<Address>Reply data.
sentDatestringThe date when the message was sent.
receivedDatestringThe date when the message was received.
subjectstringMessage's subject.
descriptionstringAndroid ONLY. Optional. Short description.
fileNamestring/
dispositionstringAndroid ONLY. Optional. /
flagsArray<string>Message's active flags
lineCountnumberAndroid ONLY. Optional. /
allMessageHeadersobjectAndroid ONLY. Optional. All Headers available on a message
contentTypestringAndroid ONLY. Optional. Type of message's content
bodyContentArray<Content>Message's body with its content and attachments.
sizenumberMessage's memory size

Address

ParamTypeDescription
addressstringEmail address
personalstringOptional. Name of the email address's owner.
typestringAndroid ONLY. Optional. Data type

Content

ParamTypeDescription
typestringContent data type
fileNamestringOptional. The name of the file
contentstringMessage's content

ModificationResult

ParamTypeDescription
statusbooleanStatus of the applied changes
modifiedMessagesArray<number>Array with consecutive numbers of modified messages

Flag : enum

Defines a flag that can be added or removed from a message.

Note: Some flags are available only for a particular platform

Kind: static enum property of flag
Available Flags

NameTypeDescription
ANSWEREDFlags.Flag / MCOMessageFlag"ANSWERED" message flag
DRAFTFlags.Flag / MCOMessageFlag"DRAFT" message flag
FLAGGEDFlags.Flag / MCOMessageFlag"FLAGGED" message flag
RECENTFlags.FlagAndroid ONLY. "RECENT" message flag
SEENFlags.Flag / MCOMessageFlag"SEEN" message flag
USERFlags.FlagAndroid ONLY. "USER" message flag
DELETEDFlags.Flag / MCOMessageFlag"DELETED" message flag. Note: Add this flag to delete the message from the mailbox
SENTMCOMessageFlagiOS ONLY. "SENT" message flag
FORWARDEDMCOMessageFlagiOS ONLY. "FORWARDED" message flag
SubmitPendingMCOMessageFlagiOS ONLY. "SubmitPending" message flag
SUBMITTEDMCOMessageFlagiOS ONLY. "SUBMITTED" message flag

ComparisonTerm : enum

Comparison Operators. Used for listing messages by date period.

Note: Some operators are available only for a particular platform

Kind: static enum property of comparison
Available Operators

NameTypeDescription
LEReceivedDateTermAndroid ONLY. The less than or equal to operator.
LTReceivedDateTerm / MCOIMAPSearchExpressionThe less than operator.
EQReceivedDateTerm / MCOIMAPSearchExpressionThe equality operator.
NEReceivedDateTerm / MCOIMAPSearchExpressionThe not equal to operator.
GTReceivedDateTermAndroid ONLY. The greater than operator.
GEReceivedDateTerm / MCOIMAPSearchExpressionThe greater than or equal to operator.

License

ISC

Thank you

Thank you for using this plugin. If you have any suggestions on how we can improve the plugin (missing feature or bug...), feel free to contact us.