All emails sent are flagged as spam

Been trying to get mail to send all day without being flagged as spam, but they still are. My IP is not blacklisted. Here is the source for one of my emails sent to gmail:

Received: by with SMTP id dh51csp583184web;
        Wed, 27 Aug 2014 13:32:57 -0700 (PDT)
X-Received: by with SMTP id ci3mr32275276wid.57.1409171577616;
        Wed, 27 Aug 2014 13:32:57 -0700 (PDT)
Return-Path: <>
Received: from ([])
        by with ESMTP id az10si3886631wib.11.2014.
        for <>;
        Wed, 27 Aug 2014 13:32:57 -0700 (PDT)
Received-SPF: pass ( domain of designates as permitted sender) client-ip=;
       spf=pass ( domain of designates as permitted sender);
       dkim=neutral (bad version) header.i=@
Received: by (Postfix, from userid 33)
	id 0325540061; Wed, 27 Aug 2014 16:32:57 -0400 (EDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple;;
	s=mail; t=1409171577;
Subject: A Subject Here
X-PHP-Originating-Script: 0:programmessys.php
Message-Id: <>
Date: Wed, 27 Aug 2014 16:32:57 -0400 (EDT)
From: (no-reply)

Hi there,
This email was sent using PHP's mail function.

This is my SPF record:

"v=spf1 mx a ip4: -all"
Show comments

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

A small change to you TXT record:

"v=spf1 mx a ip4: ~all"

I have changed the hyphen before “all” to a tilde (~).

Also I find that you’re using Mailgun for handling incoming emails why not use it to send emails too?

Mailgun has instructions on how to configure Postfix to relay emails.

Once done do a mail test.