i am using vtiger and recieveing alot of spam on the website contact page i am using this code
I would recommend You other antiSpam method - with token/private key.
In HTML form You put this:
And add also few lines of code before IF condition - for example: fragment with SQL query or send mail, just to check/validate sended token by POST method:
AND REMEMBER! Always validate and sanitize all Your input data! :)