1

I know that this kind of question has already been asked but I've spent hours trying to solve the problem without any change. All the emails I send using PHPMailer are being seen as spam by hotmail/outlook accounts. I don't have this problem with gmail or yahoo. But outlook seems to be very very strict...

My website is stored on a Ex2 Hosting shared server. Using https://mxtoolbox.com/ I don't see any sign that the server might be blacklisted.

Both DKIM and SPF authentification are activated. And there are unsubscribe-links in both header and html/body part.

When I make a test with https://www.mail-tester.com/ the only problem detected by SpamAssassin is 'MISSING DATE'. Even if I set current date in header (see code below).

Many thanks in advance for anyone trying to help me :)

Here is my code :

    date_default_timezone_set('Europe/Paris');
$dt = new Datetime('now');


    $mail = new PHPMailer(true);

    try {

        $mail->SMTPDebug = 0;
        $mail->isSMTP();
        $mail->Host = 'my.shared-server.com';
        $mail->SMTPAuth = true;
        $mail->Username = 'contact@myfirm.com';
        $mail->Password = 'MYPASSWORD';
        $mail->SMTPSecure = 'tls';
        $mail->Port = 587;
        $mail->ReturnPath = 'contact@myfirm.com';
        $mail->setFrom('contact@myfirm.com', 'My Firm');
        $mail->addAddress($recipient, '');
        $mail->addReplyTo('contact@myfirm.com', 'My Firm');
        $mail->addCustomHeader('List-Unsubscribe', '<mailto:postmaster@myfirm.com?subject=Unsubscribe>, <https://www.myfirm.com/unsubscribe>');
        $mail->MessageDate = $dt->format('Y-m-d H:i:s T');
        $mail->CharSet = 'UTF-8';
        $mail->isHTML(true);
        $mail->Subject = $title;
        $mail->Body    = '<!DOCTYPE html>
                <html>
                    <head>
                        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
                        <style>
                            /* css code */
                        </style>
                        <title>My Firm</title>
                        <meta name="description" content="An email from My Firm">
                        <link href="https://fonts.googleapis.com/css?family=Raleway:200,300,400,500,600,700,800" rel="stylesheet">
                    </head>
                    <body>
                        <p>$message_html</p>
                    </body>
                </html>';
        $mail->AltBody = $message_text;

        $mail->send();

        echo 'Message has been sent';

    } catch (Exception $e) {

        echo 'Error';

    }
Romain B.
  • 11
  • 1
  • 1
  • see this i think helpful https://stackoverflow.com/questions/371/how-do-you-make-sure-email-you-send-programmatically-is-not-automatically-marked?rq=1 – Mazhar Hussain Jan 16 '18 at 10:11
  • Thank you @MazharHussain . Unfortunately I don't see anything that I would not respect in my procedure. And I can confirm that abuse@myfirm.com and postmaster@myfirm.com exist. But as someone said 'getting Hotmail to accept your emails remains a black art' – Romain B. Jan 16 '18 at 10:39

0 Answers0