PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Your php code is correct. Check the code were you call this script to see if you send more than one email.
If you\ clients receive the emails in Spam folders it means that the mail address is considered spam by GMail, Yahoo and possibly other mail servers. You can talk to your users\ clients to select the email from you as being not spam or change your email address. Another solution is to convince the administrators of the servers that you' re not spammer so that they remove you from the spammer list.
After seeing your post i did a little search and someone was telling something about mail signature thing, but i literally don't know about the signature thingy, it also read that phpmailer would avoid such "PROBLEM", umm since this forum predominantly opts for swift mailer, i came across this http://swiftmailer.org/wikidocs/v3/tips/spam
So maybe using swiftmailer will avoid the problem of spam TOO !!