Skip to content
/ cf-imap Public

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

License

Notifications You must be signed in to change notification settings

Exerra/cf-imap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

52 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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: "[email protected]",
        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.

About

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

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project