All emails sent are flagged as spam

August 27, 2014 2.6k views

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"
1 Answer

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.

  • i actually gave up on this and started using MailGun for outgoing mail, so that’s probably what you saw. I may try what you suggested at some point but i remember it being mentioned in another thread and not working.

  • Doing a mail test will help understand why directly sent emails are marked as spam.

Have another answer? Share your knowledge.

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