How to check for the generated password using protractor?

I have a weird scenario:

In my automation, i have to create a user. On creation, a password wil be generated and sent to his/her email id. How can i automate to retrieve the password in his/her email(NOTE:I have to open a new window to go to his/her email and enter his/her credentials and open the particular mail which has the sent password and copy it) and come back to my application and login with his/her username and password? Pretty confusing rite

And also how i can i switch to another tab(supposingly it is not an angular-app),
and execute actions to enter username and password of his email)

For the emails, you can use a package called mail-listener. You can follow the instructions on this answer, I've done it myself and it was relatively easy to setup. Then you can get the password from the parsed email.

And as far as switching to other tabs, you can use getAllWindowHandles(), something like this:

Since it's non-Angular page, you'll need to set browser.ignoreSynchronization = true. You can do this in the function when you switch window handles, or you may even want to do it right before that step. You'll need to use some Expected Conditions to control test flow. Find the necessary elements you need to interact with on the non-Angular page, i.e.:

Edit:
To open a new tab yourself via Protractor, you can use executeScript(). i.e.

browser.executeScript("window.open('http://www.google.com')");

Edit 2:
For setting up mail-listener, the code provided in the linked question was pretty much copy/paste for me with the exception of username, password, and host. The username/password will be the same user you are trying to login as. For host, it varies by email server. You should be able to find it by googling "imap host for microsoft exchange (or whatever server you are using)" or going to the settings of that email server.

Only other code I really added to that function was logging errors which might help identify your problem and why you can't connect. You can put this in the onPrepare() function of your config file: