If you want to read email form script you need to allow less secure app as same as Gmail,
Just Go to the link, after login and allow less secure app at the bottom.
Go to "Generate app password"
Select appropiate option and hit generate.
and you are good to go, this was new settings by yahoo for third party apps.