cf-imap
TypeScript icon, indicating that this package has built-in type declarations

0.0.9 • Public • Published

cf-imap

IMAP (v4) client for the Cloudflare Workers platform. Do not try to run this on other runtimes, it will not work.

Warning, this version is pre-release, so breaking changes may happen between versions. At this stage for existing functions it is unlikely, however the possibility still exists.

Initialisation

The CFImap class can be created in any part of the code, however it is advised to use the connect() function only in a request handler. That is because the Cloudflare Workers platform limits some functionality (mainly await) outside of handlers.

import { CFImap } from "cf-imap"

const imap = new CFImap({
    host: "mail.example.com",
    port: 993,
    tls: true,
    auth: {
        username: "user@example.com",
        password: "pa$$w0rd"
    }
})

const handleRequest = async () => {
    await imap.connect()
}

Logging out

The logout() function lets you log out of the session and close the socket. It is recommended to use this as to not run the Worker needlessly (some providers auto-kick you after a while, some keep the connection open indefinitely).

await imap.logout()

Documentation

Documentation can be found here.

Dependencies (0)

    Dev Dependencies (2)

    Package Sidebar

    Install

    npm i cf-imap

    Weekly Downloads

    11

    Version

    0.0.9

    License

    none

    Unpacked Size

    25.8 kB

    Total Files

    7

    Last publish

    Collaborators

    • exerra