Mail server connection using IMAP protocol
try {
const folders = imap.listFolders()
console.debug('Available folders are:', folders)
console.log('select INBOX')
imap.selectFolder('INBOX')
// Messages that have the \Recent flag set but not the \Seen flag.
// This is functionally equivalent to "(RECENT UNSEEN)"
const newSNs = imap.search('NEW')
console.log(`INBOX contains ${newSNs.length} new messages`)
if (newSNs.length) {
let msg = imap.receive(newSNs[0])
try {
inspectMessage(msg)
} finally {
msg.freeNative()
}
}
} finally {
imap.freeNative()
}
# new UBMailImap (paramsObj: object)
Arguments:
paramsObj
: objectMail server connection parameters
Methods
# closeFolder () → boolean instance
Close a selected folder. (end of Selected state)
# deleteMessage (msgSeqNum: number) → TubMimeMessBind instance
Mark the message with specified sequence number as Deleted
.
Real deleting will be done after successful closeFolder
or expungeFolder
.
Arguments:
msgSeqNum
: number
# freeNative () instance
Close IMAP connection and release all resources ASAP
# getMessagesCount (folderNameopt: string, criteriaopt: string) instance
Get a message count from a specified folder what match specified criteria
# getMessageSize (msgSeqNum: number) instance
Returns size of the message with specified sequence number
Arguments:
msgSeqNum
: number
# listFolders (initialFolderNameopt: string) → Array.<string> instance
List sub-folders of initialFolder. If initial folder is '' then list all available folders
Arguments:
initialFolderName
= '': string
# receive (msgSeqNum: number) → TubMimeMessBind instance
Receive a full message from current folder by it's sequence numbers.
To get s message sequence numbers use a search()
method.
Messages indexes are in the order they're received
Arguments:
msgSeqNum
: number
# search (criteria: string) → Array.<number> instance
Search for message sequence numbers in the selected folder
Arguments:
criteria
: stringA search criteria - see rfc3501 section-6.4.4
# selectFolder (folderName: string) → boolean instance
Select a folder by it's name. Returns true on success or throw on error
Arguments:
folderName
: string