Using PHP and NNTP to post new message to Usenet!

I've tried to write my own client to post messages to Usenet newsgroups using PHP and most scripts you'll find on the net either do not show you how to...

I've tried to write my own client to post messages to Usenet newsgroups using PHP and most scripts you'll find on the net either do not show you how to connect to a Usenet server using credentials (name/password) or they do not let you error debug the connection (leaving you blind when something goes wrong during the NNTP handshake).

Anyhow, here is a code I wrote to address both issues. I've tested it and it works. Commented line also shows, how to reply to an existing message (assuming you know the Usenet ID of the message you're replying to.