Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
imap-client
Advanced tools
High-level UMD module wrapper for [browserbox](https://github.com/whiteout-io/browserbox). This module encapsulates the most commonly used IMAP commands.
High-level UMD module wrapper for browserbox. This module encapsulates the most commonly used IMAP commands.
var ImapClient = require(‘imap-client’);
var imap = new ImapClient({
port: 993, // the port to connect to
host: ’imap.example.com’, // the host to connect to
secure: true/false, // use SSL?
ignoreTLS: true/false, // if true, do not call STARTTLS before authentication even if the host advertises support for it
requireTLS: true/false, // if true, always use STARTTLS before authentication even if the host does not advertise it. If STARTTLS fails, do not try to authenticate the user
auth.user: ’john.q@example.com’, // username of the user (also applies to oauth2)
auth.pass: ‘examplepassword’, // password for the user
auth.xoauth2: ‘EXAMPLEOAUTH2TOKEN’, // OAuth2 access token to be used instead of password
ca: ‘PEM ENCODED CERT’, // (optional, used only in conjunction with the TCPSocket shim) if you use TLS with forge, pin a PEM-encoded certificate as a string. Please refer to the [tcp-socket documentation](https://github.com/whiteout-io/tcp-socket) for more information!
maxUpdateSize: 20 // (optional) the maximum number of messages you want to receive in one update from the server
});
Log in to an IMAP Session. No-op if already logged in.
imap.login(function() {
// yay, we’re logged in
imap.logout(function() {
// yay, we’re logged out
});
});
Set up a connection dedicated to listening for changes published by the IMAP server on one specific inbox.
imap.listenForChanges({
path: ‘mailboxpath’
}, function() {
// the audience is listening
imap.stopListeningForChanges(function() {
// we’re not listening anymore
});
})
Lists folders, grouped to folders that are in the following categories: Inbox, Drafts, All, Flagged, Sent, Trash, Junk, Archive, Other.
Returns the uids of messages containing the search terms in the options.
imap.search({
answered: true
unread: true
}, function(error, uids) {
console.log(‘uids: ‘ + uids.join(‘, ‘))
});
Lists messages in the mailbox based on their UID.
imap.listMessages({
path: ‘path’, the folder's path
firstUid: 15, (optional) the uid of the first messagem defaults to 1
lastUid: 30 (optional) the uid of the last message, defaults to ‘*’
}, function(error, messages) {})
Messages have the following attributes:
Fetches parts of a message from the imap server
imap.getBodyParts({
path: 'foo/bar',
uid: someMessage.uid,
bodyParts: someMessage.bodyParts
}, function(err) {
// all done, bodyparts can now be fed to the mailreader
})
Marks a message as un-/read or un-/answered.
imap.updateFlags({
path: 'foo/bar',
uid: someMessage.uid,
unread: true/false/undefined, // (optional) Marks the message as un-/read, no action if omitted
answered: true/false/undefined // (optional) Marks the message as answered, no action if omitted
}, function (error) {
// all done
});
Moves a message from mailbox A to mailbox B.
imap.moveMessage({
path: 'foo/bar', // the origin folder
uid: someMessage.uid, // the message's uid
destination: 'bla/bli' // the destination folder
}, function (error) {
// all done
});
Uploads a message to a folder
imap.uploadMessage({
path: 'foo/bar', // the target folder
message: '...' // RFC-2822 compliant string
}, function (error) {
// all done
});
Deletes a message from a folder
imap.deleteMessage({
path: 'foo/bar', // the folder from which to delete the message
uid: someMessage.uid, // the message's uid
}, function (error) {
// all done
});
If there are updates available for an IMAP folder, you will receive the changed UIDs in the #onSyncUpdate
callback. The IMAP client invokes the callback if there are new/changes messages after a mailbox has been selected and on IMAP expunge/exists/fetch updates have been pushed from the server.
If this handler is not set, you will not receive updates from IMAP.
var SYNC_TYPE_NEW = 'new';
var SYNC_TYPE_DELETED = 'deleted';
var SYNC_TYPE_MSGS = 'messages';
imap.onSyncUpdate = function(options) {
var updatedMesages = options.list,
updatesMailbox = options.path
if (options.type === SYNC_TYPE_NEW) {
// new messages available on imap
// updatedMesages is an array of the newly available UIDs
} else if (options.type === SYNC_TYPE_DELETED) {
// messages have been deleted
// updatedMesages is an array of the deleted UIDs
} else if (options.type === SYNC_TYPE_MSGS) {
// NB! several possible reasons why this could be called.
// updatedMesages is an array of objects
// if an object in the array has uid value and flags array, it had a possible flag update
}
};
Run the following commands to get started:
npm install && grunt
The MIT License (MIT)
Copyright (c) 2014 Whiteout Networks GmbH
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
FAQs
High-level UMD module wrapper for [browserbox](https://github.com/whiteout-io/browserbox). This module encapsulates the most commonly used IMAP commands.
The npm package imap-client receives a total of 4 weekly downloads. As such, imap-client popularity was classified as not popular.
We found that imap-client demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.