How to connect to office365 with imap ?
Rebaiahmed opened this issue · 1 comments
Rebaiahmed commented
How to connect to office365 with imap ?
govindthakur25 commented
const setupMailBox = function () {
var MailListener = require('mail-listener2');
var mailListener = new MailListener({
username: 'your_outlook_id',
password: 'your_password',
host: 'outlook.office365.com',
port: 993,
tls: true,
tlsOptions: { rejectUnauthorized: false },
fetchUnreadOnStart: true
});
mailListener.start();
mailListener.on(`server:connected`, function() {
console.log('Mail listener initialized');
});
mailListener.on('server:disconnected', function() {
console.log('imapDisconnected');
});
mailListener.on('error', function(err) {
console.log('mail-listener2:: An error occurred', err);
});
global.mailListener = mailListener;
}
Then invoke this function inside your conf file:
onPrepare() {
setupMailBox();
browser.manage().window().maximize();
browser.manage().timeouts().implicitlyWait(3000);
browser.waitForAngularEnabled(false);
},
params: {
getLastEmail: function() {
var deferred = protractor.promise.defer();
console.log('Waiting for an email...');
mailListener.on('mail', function(mail) {
deferred.fulfill(mail);
});
return deferred.promise;
}
}
In spec file use it like this:
return browser.wait(browser.params.getLastEmail()).then((email) => { console.log(email) });