@lionflence/lion-imap-plugin v0.0.7
lion-imap-plugin
IMAP functionality for capacitor applications. Currently supports android only with JavaMail 1.6.6. iOS support to come!
Install
npm install @lionflence/lion-imap-plugin
npx cap sync
You will probably receive an error during the android compilation process telling you the following:
2 files found with path 'META-INF/NOTICE.md' from inputs: ...
You can fix this by excluding the files inside of the android packaging options like so:
Add the following inside your android/app/build.gradle
file (NOTE: NOT android/build.gradle
!):
android {
...
packagingOptions {
exclude 'META-INF/NOTICE.md'
exclude 'META-INF/LICENSE.md'
}
}
API
connect(...)
isConnected()
disconnect()
listMailFolders(...)
getMessageCountByFolderName(...)
getMessageByMessageId(...)
getMessagesByHeader(...)
getFullMessageData(...)
copyToFolder(...)
setFlag(...)
listMessagesHeadersByConsecutiveNumber(...)
searchMessages(...)
sendMessage(...)
getThreadForMessage(...)
getAttachmentContent(...)
deleteMessage(...)
moveMessage(...)
- Interfaces
connect(...)
connect(config: ImapConfig) => Promise<{ connected: boolean; }>
Param | Type |
---|---|
config | ImapConfig |
Returns: Promise<{ connected: boolean; }>
isConnected()
isConnected() => Promise<{ connected: boolean; }>
Returns: Promise<{ connected: boolean; }>
disconnect()
disconnect() => Promise<{ disconnected: boolean; }>
Returns: Promise<{ disconnected: boolean; }>
listMailFolders(...)
listMailFolders(call: { pattern: string; }) => Promise<{ folders: string[]; }>
Param | Type |
---|---|
call | { pattern: string; } |
Returns: Promise<{ folders: string[]; }>
getMessageCountByFolderName(...)
getMessageCountByFolderName(call: { folderName: string; }) => Promise<{ count: number; }>
Param | Type |
---|---|
call | { folderName: string; } |
Returns: Promise<{ count: number; }>
getMessageByMessageId(...)
getMessageByMessageId(call: { folderName: string; messageId: string; }) => Promise<{ message: Message; }>
Param | Type |
---|---|
call | { folderName: string; messageId: string; } |
Returns: Promise<{ message: Message; }>
getMessagesByHeader(...)
getMessagesByHeader(call: { headerName: string; headerValue: string; }) => Promise<{ messages: Message[]; }>
Param | Type |
---|---|
call | { headerName: string; headerValue: string; } |
Returns: Promise<{ messages: Message[]; }>
getFullMessageData(...)
getFullMessageData(call: { folderName: string; messageNumber: number; }) => Promise<{ message: Message; }>
Param | Type |
---|---|
call | { folderName: string; messageNumber: number; } |
Returns: Promise<{ message: Message; }>
copyToFolder(...)
copyToFolder(call: { sourceFolder: string; destinationFolder: string; messageNums: number[]; }) => Promise<boolean>
Param | Type |
---|---|
call | { sourceFolder: string; destinationFolder: string; messageNums: number[]; } |
Returns: Promise<boolean>
setFlag(...)
setFlag(call: { folderName: string; messageNums: number[]; flag: string; status: string; }) => Promise<boolean>
Param | Type |
---|---|
call | { folderName: string; messageNums: number[]; flag: string; status: string; } |
Returns: Promise<boolean>
listMessagesHeadersByConsecutiveNumber(...)
listMessagesHeadersByConsecutiveNumber(call: { folderName: string; start: number; end: number; query?: string; }) => Promise<{ messages: Message[]; }>
Param | Type |
---|---|
call | { folderName: string; start: number; end: number; query?: string; } |
Returns: Promise<{ messages: Message[]; }>
searchMessages(...)
searchMessages(call: { query: string; page: number; limit: number; folderName: string; }) => Promise<{ messages: Message[]; }>
Param | Type |
---|---|
call | { query: string; page: number; limit: number; folderName: string; } |
Returns: Promise<{ messages: Message[]; }>
sendMessage(...)
sendMessage(call: { content: string; subject: string; from: string; to: MessageAddress[]; cc: MessageAddress[]; bcc: MessageAddress[]; attachments: any[]; }) => Promise<{ sent: boolean; }>
Param | Type |
---|---|
call | { content: string; subject: string; from: string; to: MessageAddress[]; cc: MessageAddress[]; bcc: MessageAddress[]; attachments: any[]; } |
Returns: Promise<{ sent: boolean; }>
getThreadForMessage(...)
getThreadForMessage(call: { messageId: string; }) => Promise<{ messages: Message[]; }>
Param | Type |
---|---|
call | { messageId: string; } |
Returns: Promise<{ messages: Message[]; }>
getAttachmentContent(...)
getAttachmentContent(call: { messageId: string; folderName: string; offset: number; }) => Promise<{ content: string; }>
Param | Type |
---|---|
call | { messageId: string; folderName: string; offset: number; } |
Returns: Promise<{ content: string; }>
deleteMessage(...)
deleteMessage(call: { messageId: string; }) => Promise<{ deleted: boolean; }>
Param | Type |
---|---|
call | { messageId: string; } |
Returns: Promise<{ deleted: boolean; }>
moveMessage(...)
moveMessage(call: { messageId: string; folderName: string; }) => Promise<{ moved: boolean; }>
Param | Type |
---|---|
call | { messageId: string; folderName: string; } |
Returns: Promise<{ moved: boolean; }>
Interfaces
ImapConfig
Prop | Type |
---|---|
username | string |
imapHost | string |
smtpHost | string |
imapPort | number |
smtpPort | number |
password | string |
Message
Prop | Type |
---|---|
messageNumber | number |
messageId | string |
subject | string |
previewText | string |
folder | string |
from | MessageAddress[] |
toRecipients | MessageAddress[] |
receivedDate | Date |
sentDate | Date |
bodyContent | MessagePart[] |
allMessageHeaders | MessageHeaders |
attachments | MessageAttachment[] |
MessageAddress
Prop | Type |
---|---|
address | string |
personal | string |
type | string |
Date
Enables basic storage and retrieval of dates and times.
Method | Signature | Description |
---|---|---|
toString | () => string | Returns a string representation of a date. The format of the string depends on the locale. |
toDateString | () => string | Returns a date as a string value. |
toTimeString | () => string | Returns a time as a string value. |
toLocaleString | () => string | Returns a value as a string value appropriate to the host environment's current locale. |
toLocaleDateString | () => string | Returns a date as a string value appropriate to the host environment's current locale. |
toLocaleTimeString | () => string | Returns a time as a string value appropriate to the host environment's current locale. |
valueOf | () => number | Returns the stored time value in milliseconds since midnight, January 1, 1970 UTC. |
getTime | () => number | Gets the time value in milliseconds. |
getFullYear | () => number | Gets the year, using local time. |
getUTCFullYear | () => number | Gets the year using Universal Coordinated Time (UTC). |
getMonth | () => number | Gets the month, using local time. |
getUTCMonth | () => number | Gets the month of a Date object using Universal Coordinated Time (UTC). |
getDate | () => number | Gets the day-of-the-month, using local time. |
getUTCDate | () => number | Gets the day-of-the-month, using Universal Coordinated Time (UTC). |
getDay | () => number | Gets the day of the week, using local time. |
getUTCDay | () => number | Gets the day of the week using Universal Coordinated Time (UTC). |
getHours | () => number | Gets the hours in a date, using local time. |
getUTCHours | () => number | Gets the hours value in a Date object using Universal Coordinated Time (UTC). |
getMinutes | () => number | Gets the minutes of a Date object, using local time. |
getUTCMinutes | () => number | Gets the minutes of a Date object using Universal Coordinated Time (UTC). |
getSeconds | () => number | Gets the seconds of a Date object, using local time. |
getUTCSeconds | () => number | Gets the seconds of a Date object using Universal Coordinated Time (UTC). |
getMilliseconds | () => number | Gets the milliseconds of a Date, using local time. |
getUTCMilliseconds | () => number | Gets the milliseconds of a Date object using Universal Coordinated Time (UTC). |
getTimezoneOffset | () => number | Gets the difference in minutes between the time on the local computer and Universal Coordinated Time (UTC). |
setTime | (time: number) => number | Sets the date and time value in the Date object. |
setMilliseconds | (ms: number) => number | Sets the milliseconds value in the Date object using local time. |
setUTCMilliseconds | (ms: number) => number | Sets the milliseconds value in the Date object using Universal Coordinated Time (UTC). |
setSeconds | (sec: number, ms?: number | undefined) => number | Sets the seconds value in the Date object using local time. |
setUTCSeconds | (sec: number, ms?: number | undefined) => number | Sets the seconds value in the Date object using Universal Coordinated Time (UTC). |
setMinutes | (min: number, sec?: number | undefined, ms?: number | undefined) => number | Sets the minutes value in the Date object using local time. |
setUTCMinutes | (min: number, sec?: number | undefined, ms?: number | undefined) => number | Sets the minutes value in the Date object using Universal Coordinated Time (UTC). |
setHours | (hours: number, min?: number | undefined, sec?: number | undefined, ms?: number | undefined) => number | Sets the hour value in the Date object using local time. |
setUTCHours | (hours: number, min?: number | undefined, sec?: number | undefined, ms?: number | undefined) => number | Sets the hours value in the Date object using Universal Coordinated Time (UTC). |
setDate | (date: number) => number | Sets the numeric day-of-the-month value of the Date object using local time. |
setUTCDate | (date: number) => number | Sets the numeric day of the month in the Date object using Universal Coordinated Time (UTC). |
setMonth | (month: number, date?: number | undefined) => number | Sets the month value in the Date object using local time. |
setUTCMonth | (month: number, date?: number | undefined) => number | Sets the month value in the Date object using Universal Coordinated Time (UTC). |
setFullYear | (year: number, month?: number | undefined, date?: number | undefined) => number | Sets the year of the Date object using local time. |
setUTCFullYear | (year: number, month?: number | undefined, date?: number | undefined) => number | Sets the year value in the Date object using Universal Coordinated Time (UTC). |
toUTCString | () => string | Returns a date converted to a string using Universal Coordinated Time (UTC). |
toISOString | () => string | Returns a date as a string value in ISO format. |
toJSON | (key?: any) => string | Used by the JSON.stringify method to enable the transformation of an object's data for JavaScript Object Notation (JSON) serialization. |
MessagePart
Prop | Type |
---|---|
content | string |
disposition | string |
type | string |
fileName | string |
MessageHeaders
MessageAttachment
Prop | Type |
---|---|
content | string |
fileName | string |
type | string |
size | number |