I've been reading a little about this and have found something called "sender policy framework" which looks like it will help with identifying mail correctly. Will this increase the chances of my sent mail not being marked as spam? Or will it simply increase the chances of spam sent with my domain in the headers being marked as spam?
Where can I find good practices on sending mail from a server?
One thing that is important is that I will be setting up google apps so that my client can use mail.example.com to get/send email. How can my server work correctly with these settings so that both mail sent from google apps and mail sent from the server (php code) are identified as authentic?
Sender Policy Framework (SPF) is a scheme that lets domain owners/admins indicate which servers are permitted to send mail on behalf of their domain.
When used and trusted by receiving servers, it can filter out messages that do not originate from you, but claim to.
It is therefore not relevant for trying to ensure mail that is sent from you is accepted. That is a reputational issue. Make sure your mail server is not on a declared-home-broadband-IP, which might be listed in a policy block list such as http://www.spamhaus.org/pbl/ . If you are trying to send mail from a residential IP, configure your MTA to route via a smarthost that isn't, such as your ISP.
read the listing policies for http://www.rfc-ignorant.org/ and make sure your mail server isn't violating any of those rules. Check your server to make sure it is minimally secure via a mail relay tester such as http://www.abuse.net/relay.html .
The grand answer is "It Depends". Correctly defined SPF records can help your mail be correctly categorized by many spam filters, but not all. Spammers usually setup SPF records, so spam filtering companies don't blindly trust anyone who sets them up. A good filter combines an SPF match, with a reputation system, so if you send clean mail, and you use SPF you are better off.
So it's a good idea to add it, but it isn't going to necessarily solve all of your problems.
SPF works by validating the host IP (or network) from which the message originated. It shouldn't matter how it was sent, as long as it is coming from a host that is validated by SPF.
SPF's job is to validate that a message is sent from correct hosts. So, if you have a lot of mail that is being spoofed with your domain and causing your domain to look spammy, SPF will help with that. But it doesn't help on per-message content that content filters think look spammy. That is, you can send a message from a valid host with words like "Viagra and Cialis" and still get it marked as spam.