imap.n.mail.yahoo.com and imap.mail.yahoo.com are the same server based on what I'm seeing them resolve to. Also,
RFC 2971 adds "IMAP ID", a way of identifying clients. It's possible Yahoo enforces this RFC on their server.
I did try setting up my Yahoo account on my iPhone, and it works fine, but no luck in Mail. Using default settings, it tries pop and asks me to subscribe to Yahoo Mail Plus. Using IMAP, mail reports back that the server is not responding. Didn't matter if I had SSL on or not, nor trying ports 143 and 993. Telnetting to the server on 143 does result in a normal looking IMAP response, so they are doing something to block clients.