6

I have used a testing service (verifier.port25.com) to check what was happening when emails were getting sent from my PHP script. For some reason they were ending up in my GMail spam folder even though SPF and DKIM are enabled.

It turns out that the SpamAssassin score was 5.3, thus above the 5.0 benchmark. Below you can see why. The biggest problem is that I have a domain with 12 letters in it (it seems crazy to me that I should be punished for this but apparently 12 letter domains are popular among spammers). As I don't want to have to change my domain, it looks like the next best option is to set a header for the date, but I am not sure how to do this. Could someone help with this?

1.0 MISSING_HEADERS Missing To: header

0.0 HTML_MESSAGE BODY: HTML included in message

-0.5 BAYES_05 BODY: Bayes spam probability is 1 to 5% [score: 0.0345]

-0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain

0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid

-0.1 DKIM_VALID Message has at least one valid DKIM or DK signature

1.4 MISSING_DATE Missing Date: header

3.5 FROM_12LTRDOM From a 12-letter domain

Existing Array

    $headers = array(
                    'From'          => $from,
                    'Return-Path'   => $sender,
                    'Subject'       => $subject
                    );
Nick
  • 3,930
  • 14
  • 62
  • 107

1 Answers1

10

Try adding this to your headers.

"Date: ".date("r")."\r\n"

For the array:

$headers = array(
                'From'          => $from,
                'Return-Path'   => $sender,
                'Subject'       => $subject,
                'Date'  => date("r")
                );
aynber
  • 17,808
  • 7
  • 43
  • 52
  • Thanks, how would I format that to include it in the array I have for my headers? – Nick Jul 24 '12 at 14:46
  • What's your existing array for the headers? – aynber Jul 24 '12 at 14:48
  • I have added the existing array to the end of my question – Nick Jul 24 '12 at 14:53
  • Then it would be about the same. 'Date' => date("r") – aynber Jul 24 '12 at 14:59
  • I added the array to my answer. – aynber Jul 24 '12 at 15:01
  • While you're at it, you may want to add 'To' headers in the same way (if you're mass mailing, you can do an array_merge right in the send loop) – arcyqwerty Jul 24 '12 at 15:10
  • @aynber Thanks, that has lowered my spam score now. I imagine there is nothing I can do about the 12-letter domain issue?? – Nick Jul 24 '12 at 15:11
  • @arcyqwerty At the moment I simply have `$recipient = "****@gmail.com";` and then `$result = $mail->send($recipient, $headers, $body);` How would I amend this to work with the 'To' headers? I am not mass mailing, just send one email at a time. – Nick Jul 24 '12 at 15:14
  • OK, I just added `'To'=> $recipient,` and now my spam score is even lower! Thanks – Nick Jul 24 '12 at 15:26