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

How can I only recieve the newest email instead of all of unread emails? #66

Open
wnbupt opened this issue May 18, 2017 · 12 comments
Open

Comments

@wnbupt
Copy link

wnbupt commented May 18, 2017

Everytime I use
mailListener.on("mail", function(mail, seqno, attributes){}
I can get all of unseen Emails, But I just want to receive the new coming emails.
Looking for help, Thank you

@dreams-and-thoughts
Copy link

Have you tried this setting?

fetchUnreadOnStart: false, // use it only if you want to get all unread email on lib start. Default is false,

@wnbupt
Copy link
Author

wnbupt commented Jun 2, 2017

Yes.
But it only helps on the beginning.
When I recieve new email later,I will get all the unread mails again.Maybe the problem is that I can't mark my emails as seen.By the way,I am using QQ mail, not Gmail. THX
l @comfytoday

@rafaelcmrj
Copy link

same here... @wnbupt did you figure this out?

@rajavijayavendan
Copy link

I am facing the same issue. Any possible fix?

@mayeaux
Copy link

mayeaux commented May 22, 2018

Make sure to set markSeen: true when you originally fetch your emails

@rajavijayavendan
Copy link

Thanks anyways @mayeaux .I am already doing it. But no use

@rajavijayavendan
Copy link

This is my search filter
searchFilter: ["UNSEEN"], markSeen: true

@mayeaux
Copy link

mayeaux commented May 25, 2018

Can you post your full set of code? Will help to see everything going on

@rajavijayavendan
Copy link

rajavijayavendan commented May 25, 2018

var mailListener = new MailListener({
username: mailConfigOption.listener.user,
password: mailConfigOption.listener.pass,
host: mailConfigOption.host,
port: 993, // imap port
tls: true,
connTimeout: 10000,
authTimeout: 5000,
debug: console.log,
tlsOptions: { rejectUnauthorized: false },
mailbox: "INBOX",
searchFilter: ["UNSEEN"],
markSeen: true,
fetchUnreadOnStart: false,
mailParserOptions: { streamAttachments: false },
attachments: true,
attachmentOptions: { directory: "uploads/" }
});

mailListener.start(); // start listening

// stop listening
// mailListener.stop();

mailListener.on("server:connected", function () {
console.log("imapConnected");
});

mailListener.on("server:disconnected", function () {
console.log("imapDisconnected");
});

mailListener.on("error", function (err) {
console.log(err);
});

mailListener.on("mail", function (mail, seqno, attributes) {
MailFeedProcessor.processMailFeed(mail, seqno, attributes);
});`

@mayeaux

@amrsa1
Copy link

amrsa1 commented Oct 23, 2019

does anyone knows how to throw an error if the email wasn't received, when i set specific filter pramater that should make test fail as there are no emails, console print "wait for email" then after 60 sec print "impaDisconnected" but protractor waiting and wont terminate the test , i have tried to add test time out but didnt work gives same result

it('1-should login with a registration code sent to an email', function (done) { setTimeout(function () { flow.execute(browser.params.getLastEmail) .then(function (email) { expect(email.subject) .toEqual('[email protected] submitted feedback'); expect(email.headers.to) .toEqual('[email protected]'); expect(email.html.includes('User feedback details: accountId: 12345, related To: dashboard, description: ' + D.feedbackMsg + '')) .toEqual(true); console.log(email.html); done(); }); }, 5000); }); });

@hesyar
Copy link

hesyar commented Jun 22, 2020

Any solution on this? I face the same problem

@ZumelzuR
Copy link

I solved like, on the protractor config, onPrepare

        var currentTime =  new Date().getTime()
        var mailListener = new MailListener({
              ...
              markSeen: true,
              port: 993, // imap port 
              tls: true,
              searchFilter: ["UNSEEN",["SINCE", currentTime + 10000]]
                ...
})

...

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

8 participants