So I'm trying to send emails from 4 websites hosted on Hostgator, all different domain names. I'm using PHPMailer to send these, they seem to work fine for every other domain except outlook.com and hotmail.com addresses.
These addresses always go into junk.
I'm not talking about a single user, I'm talking about every subscriber, sometimes it's a sign up email which required user validation. The solution isn't to whitelist my domain.
Below is my php code (details removed) . It's not spam, the latest example my domain is new.
The account I'm sending it from is valid, no bounce back emails.
Emails send fine to gmail, ymail and every other business address I have. It's only Microsoft domains which are a problem.
This problem is consistent with myself and an associate.
Multiple hostgator support agents have confirmed DKIM, SPF records are correct.
Why are these being treated as spam.
<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception;
require 'vendor/autoload.php';
$mail = new PHPMailer(true);
try {
$mail->SMTPDebug = SMTP::DEBUG_SERVER;
$mail->isSMTP();
$mail->SMTPAuth = true;
$mail->Host = 'mail.mydomain.com';
$mail->SMTPSecure = "ssl";
$mail->Username = 'name@mydomain.com';
$mail->Password = 'mypassword';
$mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS;
$mail->Port = 465;
$mail->SMTPOptions = array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
)
);
$mail->setFrom('name@mydomain.com');
$mail->addAddress('joeuser@gmail.com', 'Joe User');
$mail->addAddress('joeuser@hotmail.com', 'Joe User');
$mail->isHTML(true);
$mail->Subject = 'Here is the subject';
$mail->Body = 'This is the HTML message body <b>in bold!</b>';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
$mail->send();
echo 'Message has been sent';
} catch (Exception $e) {
echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
}