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

How to connect to office365 with imap ? #80

Open
Rebaiahmed opened this issue Aug 31, 2018 · 1 comment
Open

How to connect to office365 with imap ? #80

Rebaiahmed opened this issue Aug 31, 2018 · 1 comment

Comments

@Rebaiahmed
Copy link

No description provided.

@govindthakur25
Copy link

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) });

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

2 participants