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

Output is not generated. #68

Open
mchopra1004 opened this issue Aug 22, 2017 · 5 comments
Open

Output is not generated. #68

mchopra1004 opened this issue Aug 22, 2017 · 5 comments

Comments

@mchopra1004
Copy link

mchopra1004 commented Aug 22, 2017

Hi,
I used the below snippet. Although it does not return any error but it does not produce any output. I think the code from line mailListener.on does not execute (Please help.!!!
var MailListener = require("mail-listener2");

	 var mailListener = new MailListener({
	   username: "[email protected]",
	   password: "test",
	   host: "imap.gmail.com",
	   port: 993, // imap port
	   tls: true,
	   connTimeout: 10000, // Default by node-imap 
	   authTimeout: 5000, // Default by node-imap, 
	   debug: console.log, // Or your custom function with only one incoming argument. Default: null 
	   tlsOptions: { rejectUnauthorized: false },
	   mailbox: "INBOX", // mailbox to monitor 
	   searchFilter: ["UNSEEN", "FLAGGED"],
	   markSeen: true, // all fetched email willbe marked as seen and not fetched next time 
	   fetchUnreadOnStart: true, // use it only if you want to get all unread email on lib start. Default is `false` 
	   mailParserOptions: {streamAttachments: true}, // options to be passed to mailParser lib. 
	   attachments: true, // download attachments as they are encountered to the project directory 
	   attachmentOptions: { directory: "attachments/" }
	 });
	  
	 mailListener.start();
	 mailListener.on("server:connected", function(){
	   console.log("imapConnected");
	 });
	   
	 mailListener.on("mail:arrived", function(id){
	   console.log("new mail arrived with id:" + id);
	 });
	  
	 mailListener.on("mail:parsed", function(mail){
	   // do something with mail object including attachments 
	   console.log("emailParsed", mail.attachments);
	   // mail processing code goes here 
	 });
@rphansen91
Copy link

@mchopra1004

Add an error handler to log any errors during setup

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

If "imapConnected" is logged on a successful connection my next issue was the searchFilter property. I had to remove the "FLAGGED" filter to see requests

@demisx
Copy link

demisx commented Sep 26, 2018

Same here. Removing "FLAGGED" value from searchFilter made my code finally see Gmail emails. Thank you @rphansen91!

@chemi392
Copy link

chemi392 commented Dec 3, 2018

I also had to remove "FLAGGED" from the filter to be able to see emails from an iRedMail server.

@VivekPowar
Copy link

After running the above code getting Error

mime.extension is not a function

@tombburnell
Copy link

I get the same as this..

If "FLAGGED" is set, then I see debug log that messages are arrived but the on("mail".. handler does not fire.

If I remove FLAGGED, then the parsing is failing with mime.extension is not a function.

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

6 participants