我将 Hoodiecrow (http://hoodiecrow.com/)用作IMAP服务器,将 mail-listener2 (https://www.npmjs.com/package/mail-listener2)用作IMAP客户端。两者都是npm模块。
我正在尝试使用mail-listener2客户端从Hoodiecrow检索消息。
这是我的mail-listener2配置:
var MailListener = require('mail-listener2');
// here goes your email connection configuration
var mailListener = new MailListener({
username: 'testuser',
password: 'testpass',
host: 'localhost',
port: 1143, // imap port
tls: false,
tlsOptions: {rejectUnauthorized: true},
mailbox: 'INBOX', // mailbox to monitor
searchFilter: ['UNSEEN'], // 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
});
mailListener.start();
mailListener.on("server:connected", function () {
console.log("Mail listener initialized");
});
var getLastEmail = function () {
var deferred = protractor.promise.defer();
console.log("Waiting for an email...");
mailListener.on("mail", function (mail) {
deferred.fulfill(mail);
});
return deferred.promise;
};
global.mailListener = mailListener;
global.getLastEmail = getLastEmail;
但是,我不确定如何配置我的应用程序以使用Hoodiecrow IMAP服务器。
有人可以帮忙吗?