I was first thinking of suggesting curl for you, but the syntax is a lot better in a language like python... and from looking around smtp does seem like a basic tcp connection like how http websites work (unless you want portability, curl is great for that).
step 1: figure out if you are using winsock(windows) or bsdsock(linux)
step 2: find a website with documentation (winsock: msdn/IBM, bsdsock: one of the many gnu doc sites)
step 3: go through every function, read what they return, and error check everything correctly, and if you are lucky you will find an example showing you how it is done.
There may be a firewall, or you are missing a critical part of your code like WSA startup or something like that.
also avoid posting questions on forums without putting a bit of effort in error checking, or at least say in your post that you removed the error checks for shortening the code. And it always helps to put out something that compiles.
You must download and install https://www.wireshark.org/
If you're writing any kind of networking s/w, it's invaluable because it allows you to see what's going on.
In particular, being able to see the difference between