Spam and how to make warning with php in website when there is an new email

i use mail() to send an email but it always sent in spam, how to fix it? and i want to make php script to show something like “warning” in my website when there is any new email, how to do it?
please, really need your help!

Spam mails is a complex subject.

First off, are you sending a properly formatted header? The fourth parameter in mail();

Besides that, the rest of the settings are outside of PHP, namely on the mail server.