chadxz / imap-simple

Wrapper over node-imap, providing a simpler api for common use cases
MIT License
243 stars 80 forks source link

onclose, onend, onerror not working properly? #91

Closed patryk-matis closed 3 years ago

patryk-matis commented 3 years ago

I'm trying to make this work:

        const config = {
            imap: {
                user: process.env.EMAIL_ACCOUNT,
                password: process.env.EMAIL_PASSWORD,
                host: process.env.HOST,
                port: 993,
                tls: true,
                authTimeout: 3000
            },

            onclose: function(){
                console.log("onclose");
            },

            onend: function(){
                console.log("onend");
            },

            onupdate: function(){
                console.log("update");
                connection.end();
            },
        }

        const connection = await imaps.connect(config);
        connection.openBox('INBOX');

But onclose and onend listeners are not doing anything? Console prints only "update". Then connection is ended.

patryk-matis commented 3 years ago

I had to use handlers outside of a config. Everything works fine.