I occasionally work on an article I want eventually finish regarding this very topic and your biggest obstacle is going to be the encryption that these servers require to authenticate (AUTH) your account. Do yourself a favor and use a library for this part, you'll save yourself a migraine or ten.