A relaying error typically means that your client is trying to send an email to a recipient that is outside the system that you are connected to, but your client is not authorized to do so. Looking at your code, you are not attempting to authenticate yourself to the server at all.
For one thing, you are using the HELO command, and you are using it incorrectly at that. The input parameter to HELO is YOUR MACHINE NAME, but you are sending the SMTP SERVER HOSTNAME instead. You need to fix that.
After that, you should use the EHLO command instead of the HELO command. EHLO will allow your client to determine which authentication schemes (amongst other features) the server actually supports (such as LOGIN, NTLM, SHA1, MD5, etc). Then you can pick one that you support and use it to log in to an actual user account that has relaying permissions.
Another problem with your code is that it is not doing any SMTP-level error handling at all. You are looking at socket error codes, but you are not looking for SMTP error codes at all. For instance, if the server rejects the MAIL FROM or RCPT TO command (which it is in this situation), your code is still going to waste bandwidth and processing time sending a DATA command that will fail (with another SMTP error you are not looking for).