I am sending the same message through the PHP mail() function using two different addresses in the header. When I send the email with email@example.com it is marked as spam by gmail but when I send the exact same email with firstname.lastname@example.org it goes directly to the inbox. I have tried this with several different messages but with the same results. Does anyone know why the email@example.com isn't being marked as spam but firstname.lastname@example.org is? Would it make a difference that I have an account on the server with the name of admin? Both emails are able to receive mail.
In general it is not possible to easily determine why a particular message has been marked as spam by the Google Mail spam filters.
Having said that however one item that is an easy test is to check whether email@example.com is in your recipients contact list. Contacts are far less likely to have their emails marked as spam.
You should also review the bulk sender guidelines posted by Google here;
This contains a whole host of things that you should be doing to ensure your emails are not routinely marked as spam.