This should get you started:
import poplib
from email import parser
pop_conn = poplib.POP3_SSL('pop.gmail.com')
pop_conn.user('username')
pop_conn.pass_('password')
After these lines just check if there was an error connecting. You can do the same easily for Hotmail and probably for Yahoo too.