Suggest you take a look at the open-source IMap X2 facility: there's source code here with annotation about accessing Yahoo Mail: [
^]
When you say have all the valid credentials, does that include your registering with YDN, and getting both consumer, and secret, keys ?
Note that Yahoo mail facility now uses OAuth for access permission, but, "The recommended authentication method for access to a Yahoo! user's mail account is OAuth. While you may still use the Browser Based Authentication (BBAuth) API, it has been deprecated."
Yahoo OAuth: [
^]
There are articles here on CP that talk about using OAuth.