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';
}