In my case this issue has nothing at all to do with moving in and out of WiFi. I have 6 different emails set up on my Droid Max and I had the same issue with my Droid X. Periodically for no reason my email accounts will start giving me messages that it can't log in. It may happen to one or two of them or all six of them will suddenly not want to log in. Sometimes, if I ignore it, it resolves it's self but I can't go 24 hours without being able to get to my emails via my phone. It's a real PIA.
My experience is, this has nothing at all to do with the settings on your phone. How could it be, I've set up my accounts and used them for months and months with no problem and then boom all of the sudden something changes?
Here is what I found that has worked for me.
Log onto your Yahoo account. There are several ways to do this. I usually just log onto the Yahoo email for whichever account is giving me issues.
Then go to the "gear" icon in the upper right hand corner and select "account info", it's currently the last selection on that list. It will make you log into your account.
Now go to the "Account Security" menu option on the left.
On the bottom of this screen is an option for "Allow Apps that Use Less Security Sign In" mine is always set to "On",
Turn this "OFF"
(Don't ask me why I do the following but I do and it's worked, menu options are on the upper left of the screen)
click on the "Preferences" menu option, let that screen load
click on the "Recent Activity" menu option, let that screen load
click back on the "Account Security" menu option and turn that same option "Allow Apps that Use Less Security Sign In" back to "On"
Now close the "Account" screen and go back to your email screen. You should see two emails from Yahoo stating your Account Options have changed.
Once I see these two emails, I go back to my phone and it is usually working again and I can see the two emails from Yahoo that I was just talking about.
I can't explain why this works, I just know it always seems to fix the issue for me. I think something in Yahoo's security utilities get's confused and until you turn it off and restart it, you're jammed up.
Hope this helps some of those having this issue