1.0.160 • Published 10 days ago

imapflow v1.0.160

Weekly downloads
2,183
License
MIT
Repository
github
Last release
10 days ago

ImapFlow

ImapFlow is a modern and easy-to-use IMAP client library for Node.js.

!NOTE Managing an IMAP connection is cool, but if you are only looking for an easy way to integrate email accounts, then ImapFlow was built for EmailEngine Email API. It's a self-hosted software that converts all IMAP accounts to easy-to-use REST interfaces.

The focus for ImapFlow is to provide easy to use API over IMAP. Using ImapFlow does not expect knowledge about specific IMAP details. A general understanding is good enough.

IMAP extensions are handled in the background, so, for example, you can always request labels value from a {@link FetchQueryObject|fetch()} call, but if the IMAP server does not support X-GM-EXT-1 extension, then labels value is not included in the response.

Source

Source code is available from Github.

Usage

First install the module from npm:

npm install imapflow

next import the ImapFlow class into your script:

const { ImapFlow } = require('imapflow');

Promises

All ImapFlow methods use Promises, so you need to wait using await or wait for the then() method to fire until you get the response.

const { ImapFlow } = require('imapflow');
const client = new ImapFlow({
    host: 'ethereal.email',
    port: 993,
    secure: true,
    auth: {
        user: 'garland.mcclure71@ethereal.email',
        pass: 'mW6e4wWWnEd3H4hT5B'
    }
});

const main = async () => {
    // Wait until client connects and authorizes
    await client.connect();

    // Select and lock a mailbox. Throws if mailbox does not exist
    let lock = await client.getMailboxLock('INBOX');
    try {
        // fetch latest message source
        // client.mailbox includes information about currently selected mailbox
        // "exists" value is also the largest sequence number available in the mailbox
        let message = await client.fetchOne(client.mailbox.exists, { source: true });
        console.log(message.source.toString());

        // list subjects for all messages
        // uid value is always included in FETCH response, envelope strings are in unicode.
        for await (let message of client.fetch('1:*', { envelope: true })) {
            console.log(`${message.uid}: ${message.envelope.subject}`);
        }
    } finally {
        // Make sure lock is released, otherwise next `getMailboxLock()` never returns
        lock.release();
    }

    // log out and close connection
    await client.logout();
};

main().catch(err => console.error(err));

Documentation

API reference.

License

© 2020-2024 Postal Systems OÜ

Licensed under MIT-license

1.0.160

10 days ago

1.0.159

20 days ago

1.0.158

1 month ago

1.0.157

1 month ago

1.0.156

2 months ago

1.0.155

2 months ago

1.0.154

2 months ago

1.0.153

2 months ago

1.0.152

3 months ago

1.0.151

3 months ago

1.0.150

3 months ago

1.0.149

3 months ago

1.0.148

4 months ago

1.0.145

6 months ago

1.0.147

6 months ago

1.0.146

6 months ago

1.0.144

8 months ago

1.0.143

8 months ago

1.0.141

8 months ago

1.0.132

10 months ago

1.0.131

10 months ago

1.0.134

10 months ago

1.0.133

10 months ago

1.0.130

11 months ago

1.0.136

9 months ago

1.0.135

9 months ago

1.0.129

11 months ago

1.0.128

1 year ago

1.0.127

1 year ago

1.0.121

1 year ago

1.0.123

1 year ago

1.0.122

1 year ago

1.0.125

1 year ago

1.0.124

1 year ago

1.0.126

1 year ago

1.0.120

1 year ago

1.0.110

2 years ago

1.0.112

2 years ago

1.0.111

2 years ago

1.0.118

1 year ago

1.0.117

1 year ago

1.0.119

1 year ago

1.0.114

1 year ago

1.0.113

2 years ago

1.0.116

1 year ago

1.0.115

1 year ago

1.0.107

2 years ago

1.0.106

2 years ago

1.0.109

2 years ago

1.0.108

2 years ago

1.0.105

2 years ago

1.0.104

2 years ago

1.0.101

2 years ago

1.0.100

2 years ago

1.0.103

2 years ago

1.0.102

2 years ago

1.0.99

2 years ago

1.0.98

2 years ago

1.0.97

2 years ago

1.0.96

2 years ago

1.0.91

2 years ago

1.0.95

2 years ago

1.0.94

2 years ago

1.0.93

2 years ago

1.0.92

2 years ago

1.0.88

2 years ago

1.0.87

2 years ago

1.0.86

2 years ago

1.0.89

2 years ago

1.0.90

2 years ago

1.0.79

2 years ago

1.0.80

2 years ago

1.0.84

2 years ago

1.0.83

2 years ago

1.0.82

2 years ago

1.0.81

2 years ago

1.0.85

2 years ago

1.0.77

2 years ago

1.0.78

2 years ago

1.0.76

3 years ago

1.0.75

3 years ago

1.0.73

3 years ago

1.0.72

3 years ago

1.0.74

3 years ago

1.0.71

3 years ago

1.0.69

3 years ago

1.0.70

3 years ago

1.0.68

3 years ago

1.0.67

3 years ago

1.0.66

3 years ago

1.0.65

3 years ago

1.0.63

3 years ago

1.0.60

3 years ago

1.0.59

3 years ago

1.0.58

3 years ago

1.0.57

3 years ago

1.0.56

3 years ago

1.0.55

3 years ago

1.0.54

3 years ago

1.0.53

3 years ago

1.0.52

3 years ago

1.0.51

4 years ago

1.0.49

4 years ago

1.0.50

4 years ago

1.0.48

4 years ago

1.0.47

4 years ago

1.0.46

4 years ago

1.0.45

4 years ago

1.0.44

4 years ago

1.0.43

4 years ago

1.0.42

4 years ago

1.0.41

4 years ago

1.0.40

4 years ago

1.0.39

4 years ago

1.0.38

4 years ago

1.0.37

4 years ago

1.0.36

4 years ago

1.0.35

4 years ago

1.0.34

4 years ago

1.0.33

4 years ago

1.0.32

4 years ago

1.0.31

4 years ago

1.0.30

4 years ago

1.0.29

4 years ago

1.0.28

4 years ago

1.0.27

4 years ago

1.0.26

4 years ago

1.0.25

4 years ago

1.0.24

4 years ago

1.0.22

4 years ago

1.0.23

4 years ago

1.0.21

4 years ago

1.0.19

4 years ago

1.0.20

4 years ago

1.0.18

4 years ago

1.0.17

4 years ago

1.0.16

4 years ago

1.0.15

4 years ago

1.0.14

4 years ago

1.0.13

4 years ago

1.0.12

4 years ago

1.0.11

4 years ago

1.0.10

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago