How can I only recieve the newest email instead of all of unread emails?
Opened this issue · 12 comments
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
Have you tried this setting?
fetchUnreadOnStart: false, // use it only if you want to get all unread email on lib start. Default is
false,
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
same here... @wnbupt did you figure this out?
I am facing the same issue. Any possible fix?
Make sure to set markSeen: true
when you originally fetch your emails
Thanks anyways @mayeaux .I am already doing it. But no use
This is my search filter
searchFilter: ["UNSEEN"], markSeen: true
Can you post your full set of code? Will help to see everything going on
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);
});`
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('thetester@abc.com submitted feedback'); expect(email.headers.to) .toEqual('aabcttidm@abc.com'); expect(email.html.includes('User feedback details: accountId: 12345, related To: dashboard, description: ' + D.feedbackMsg + '')) .toEqual(true); console.log(email.html); done(); }); }, 5000); }); });
Any solution on this? I face the same problem
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]]
...
})
...