Spam is the use of electronic messaging systems to send unsolicited bulk messages indiscriminately.
E-mail spam, known as unsolicited bulk Email (UBE), junk mail, or unsolicited commercial email (UCE), is the practice of sending unwanted e-mail messages, frequently with commercial content, in large quantities to an indiscriminate set of recipients. Spam in e-mail started to become a problem when the Internet was opened up to the general public in the mid-1990s. It grew exponentially over the following years, and today composes some 80 to 85% of all the email in the world, by a "conservative estimate". Pressure to make e-mail spam illegal has been successful in some jurisdictions, but less so in others. Spammers take advantage of this fact, and frequently outsource parts of their operations to countries where spamming will not get them into legal trouble.
Why Did My Email Land in the Spam Folder?
Because the recipient had a filter in place. There is no way you can influence what the recipient does to block or accept your email, and hence, there is no programmatic solution to this problem. (If there was a way to make sure the email your program sends is delivered to the recipient, spammers would promptly start doing that, mail server administrators would prompty respond, and then it would no longer work.) Therefore, questions about email deliverability are off-topic for StackOverflow. See also this meta question.