Mail goes to spam when using `mail` from command line

emailspamspf

I've a CentOS 6.4 server. When I send an email using the mail command from command line, it's always marked as spam by Gmail. So, every system emails go to spam and so do every emails sent with a PHP script.

My rDNS should be fine.

$ host 158.58.168.96
96.168.58.158.in-addr.arpa domain name pointer fs1.francescoruvolo.com.

$ host fs1.francescoruvolo.com
fs1.francescoruvolo.com has address 158.58.168.96
fs1.francescoruvolo.com mail is handled by 10 mail.fs1.francescoruvolo.com.

SPF is marked as pass as you can see in these headers (from an email which gmail has marked as spam):

Delivered-To: *******@gmail.com
Received: by 10.70.8.133 with SMTP id r5csp188653pda;
        Mon, 26 Aug 2013 18:50:19 -0700 (PDT)
X-Received: by 10.15.64.1 with SMTP id n1mr30567514eex.15.1377568217754;
        Mon, 26 Aug 2013 18:50:17 -0700 (PDT)
Return-Path: <root@fs1.francescoruvolo.com>
Received: from fs1.francescoruvolo.com ([2a02:29e0:2:4::b5b6:f0bd])
        by mx.google.com with ESMTPS id q8si12101539eem.60.1969.12.31.16.00.00
        (version=TLSv1 cipher=RC4-SHA bits=128/128);
        Mon, 26 Aug 2013 18:50:17 -0700 (PDT)
Received-SPF: pass (google.com: domain of root@fs1.francescoruvolo.com designates 2a02:29e0:2:4::b5b6:f0bd as permitted sender) client-ip=2a02:29e0:2:4::b5b6:f0bd;
Authentication-Results: mx.google.com;
       spf=pass (google.com: domain of root@fs1.francescoruvolo.com designates 2a02:29e0:2:4::b5b6:f0bd as permitted sender) smtp.mail=root@fs1.francescoruvolo.com
Received: from root by fs1.francescoruvolo.com with local (Exim 4.76)
    (envelope-from <root@fs1.francescoruvolo.com>)
    id 1VE8Q9-0005lK-Q8
    for *******@gmail.com; Tue, 27 Aug 2013 03:50:13 +0200
Date: Tue, 27 Aug 2013 03:50:13 +0200
To: *******@gmail.com
Subject: 1 updates available for fs1.francescoruvolo.com
User-Agent: Heirloom mailx 12.4 7/29/08
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Message-Id: <E1VE8Q9-0005lK-Q8@fs1.francescoruvolo.com>
From: root <root@fs1.francescoruvolo.com>

RoundCube webmail 0.9.2 to 0.9.3 update is available.

Moreover, as you can see from these headers, my From field matches the address in the Received field.

What else should I try?

Best Answer

I've found a solution.

As you can see from the headers, my server was recognized by its ipv6 address, and I haven't set reverse DNS for ipv6.

Basically, if you have both ipv4 and ipv6 address, be sure that both of them are properly set. Doing every check against ipv4 when you present yourself to the world with ipv6 is nothing but pointless. :)