我是邮件收听者的新手。我能够获取gmail收件箱以及附件,但我的要求是仅提取收件箱。附件使用邮件监听器:
var mailListener = new MailListener({
username: "xxxx@gmail.com",
password: "xxx",
host: "imap.gmail.com",
port: 993, // imap port
tls: true,
//ssl: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"], // the search filter being used after an IDLE notification has been retrieved
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/" } // specify a download directory for attachments
});
相反邮箱:“INBOX”我想要一些像邮箱一样的东西:“INBOX ONLY ATTACHMENTS” 或searchfilter:“有附件”
答案 0 :(得分:0)
我不认为使用mail-listener2是个好主意。在我看来,使用这些第三方库绝不是一件好事,因为你将不得不处理很多其他问题。 Google提供了Gmail API,您可以使用该API访问收件箱,获取推送通知等。在此处阅读https://developers.google.com/gmail/api
顺便说一下,你公开了密码。