Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attributes null on mailListener.on("mail") #41

Open
stratbasher opened this issue Oct 2, 2023 · 2 comments
Open

Attributes null on mailListener.on("mail") #41

stratbasher opened this issue Oct 2, 2023 · 2 comments

Comments

@stratbasher
Copy link

stratbasher commented Oct 2, 2023

Hello,

My code worked a few days ago when I was running an older version of mailListener. I decided to run npm update yesterday. I'm not sure what version it was but it was probably about 6 months old. I tried to downgrade but I didn't see any older releases.

Using Node v19.7.0

mailListener.on("mail", async function (mail, seqno, attributes) {

    mailListener.imap.move(attributes.uid, "INBOX/Folder/here");

}

The "attributes" variable is null when trying to access the uid variable so I can move the email to another folder.

image

Any ideas on what I can troubleshoot?

@stratbasher
Copy link
Author

I'm an idiot - making it async didn't give time for imap to resolve the attributes. Removing "async" fixed the issue.

@stratbasher
Copy link
Author

stratbasher commented Oct 5, 2023

I spoke too soon. I put two log lines into parseUnread().

One in:

f.on('message', (msg, seqno) => {
    attrs=0;
    **console.log(attrs);**
}

And one in:

msg.on('body', async (stream, info) => {
    let parsed = await simpleParser(stream);
    **console.log('emitting mail');**
}

When running my code against an mailbox with existing mail, I'm getting the "emitting mail" message without any attrs. I think this has to be some sort of synchronicity issue where the 'attributes' event gets fired after 'body' does.

image

This is further reinforced by the fact that if I put some breakpoints in the mail-listener5 index.js file to manually slow things down, I will get the attributes variable.

image

@MorphedAU did you ever figure this out?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant