PHP mail() function goes to junk @ Outlook
Question by Robinjoeh
When using the PHP mail() function, the email goes to the junk folder when I use the word “utvecklat” somewhere in my message. (it doesn’t matter where)
But when I’m sending an email from Outlook to another Outlook-account (within the same mail server) it goes to the inbox.
Therefore, I think the problem is related to the mail headers.
I’m using this PHP code:
$subject='=?UTF-8?B?'.base64_encode($subject).'?=';
$emailTo="{$toEmail}";
$boundary = md5(date('U'));
$headers = "MIME-Version: 1.0rn";
$headers .= "Content-Type: multipart/alternative;boundary={$boundary}rn";
$headers .= "From: "{$fromName}" <{$fromEmail}>rn";
$message = "This is a MIME encoded message.";
$message .= "rnrn--" . $boundary . "rn";
$message .= "Content-type: text/html;charset=utf-8rnrn";
$message .= $message_tmp;
$message .= "rnrn--" . $boundary . "--";
mail($emailTo, $subject, $message, $headers, "-f {$fromEmail}");
The email should be in HTML format. It doesn’t matter if I use “utvecklat“, the email will go to the junk folder anyway.
So, what should I do to avoid the spam filter in Outlook? (must be something to do with my email headers, because mail from Outlook to Outlook within the same mailserver goes to the inbox.)
Thank you!
UPDATE!
Here you have a email sent from a outlook account to another. Can someone “convert” all this headers to a correct PHP mail() code? Thanks!
Return-Path: <example@domain.com>
Delivered-To: robin@example.com
Received: from localhost (localhost [127.0.0.1])
by example.example.com (Postfix) with ESMTP id 9C67EC21B12
for <robin@example.com>; Sat, 7 Apr 2012 17:58:14 +0200 (CEST)
X-Virus-Scanned: Debian amavisd-new at example.example.com
X-Spam-Flag: NO
X-Spam-Score: -2.47
X-Spam-Level:
X-Spam-Status: No, score=-2.47 required=6.31 tests=[ALL_TRUSTED=-1,
BAYES_00=-1.9, HTML_MESSAGE=0.001, MIME_HTML_MOSTLY=0.428,
TVD_SPACE_RATIO=0.001] autolearn=ham
Received: from example.example.com ([000.000.000.00])
by localhost (example.example.com [127.0.0.1]) (amavisd-new, port 10024)
with ESMTP id HIlqLaU+2IIL for <robin@example.com>;
Sat, 7 Apr 2012 17:58:11 +0200 (CEST)
Received: from Ciccidator (00-000-00-000-no56.tbcn.telia.com [00.00.00.000])
by example.example.com (Postfix) with ESMTPA id 866F2C2059C
for <robin@example.com>; Sat, 7 Apr 2012 17:58:11 +0200 (CEST)
From: "Example Sender" <example@domain.com>
To: <robin@example.com>
Subject: utvecklat
Date: Sat, 7 Apr 2012 17:58:01 +0200
Message-ID: <000001cd14d7$35d38070$a17a8150$@example.com>
MIME-Version: 1.0
Content-Type: multipart/alternative;
boundary="----=_NextPart_000_0001_01CD14E7.F95C9E90"
X-Mailer: Microsoft Outlook 14.0
Thread-Index: Ac0U1zWPte9QsazETMuTKG6LDnf1fg==
Content-Language: sv
Answer by Starx
Omitting the junk mail covers a lot of ground, and can never be a 100% solution. Because email filtration might be different from one span engine to other.
-
One the best way to confirm you always receive the mail is to the add the sender’s email address on the recipient’s address book.
-
Another, you should confirm if the sender’s email is not blacklisted on the internet.
-
Always confirm you have sent the emails with correct header.
-
Use Email Libraries like PHP Mailer
Fruther more: Check out this answer about MX entries.