OK, I needed to something different with code. I wanted to have a little science project because I'm tired of doing mundane things at work and keep grinding on the same shit at home. So after Diana went to bed, I decided, you know, I want to talk to Gmail. Like with bytes I'm reading and writing.
I know, that's some dorky stuff. But the thing I have in mind is to write my own POP3 client so I can, among other things, get to a point where I can suck down e-mail for the CF moblog and parse it myself, letting that shitty 3rd party component I'm using burn in hell.
Pulling down data from a POP server isn't that hard really. You send some simple commands via a TcpClient object's stream, and process what comes back. What I thought might be tricky is that Gmail, and others, require SSL to encrypt the data. As it turns out, .Net has an SslStream class, and has since v2. I guess I never noticed it because my mini-book on streams and networking is based on v1.1.
The bottom line is that you simply use the SslStream instead of NetworkStream (both eventually derived from Stream), and you're good to go. Yay!
So without showing the commands I sent, here were the responses in the test I whipped up, just logging in and getting the message index...
+OK Gpop ready for requests from x.x.x.x a30pf387042rnb.0
+OK send PASS
+OK Welcome.
+OK 12 messages (62050 bytes)
1 4272
2 3216
3 6353
4 1382
5 5286
6 6359
7 1392
8 2002
9 6446
10 6256
11 1827
12 17259
+OK Farewell.
No comments yet.