I'm using SMTP authentication, i follow the rules so it doesn't gets flagged as spam, i already looked into cname.
I'm hosting my webserver in Hostinger, but I also have some websites in Hostgator and the same occurs, i already asked for their support to activate everything so my email doesn't get flagged as spam, but nothing solves it.
Here's the code from the PHPMailer php file:
<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
require '../PHPMailer/Exception.php';
require '../PHPMailer/PHPMailer.php';
require '../PHPMailer/SMTP.php';
//Don't run this unless we're handling a form submission
function SendActivateAccountEmail($email, $name, $lastName){
//Instantiation and passing `true` enables exceptions
$mail = new PHPMailer(true);
try {
//Server settings
$mail->isSMTP(); //Send using SMTP
$mail->CharSet = 'UTF-8'; //Accepts special characters
$mail->Encoding = 'base64'; //Corrects possible problems of UTF-8 with default phpmailer encoding
$mail->Host = 'smtp.hostinger.com'; //Set the SMTP server to send through
$mail->SMTPAuth = true; //Enable SMTP authentication
$mail->Username = 'support@mywebsite.com'; //SMTP username
$mail->Password = 'password'; //SMTP password
$mail->SMTPSecure = 'ssl'; //Enable TLS encryption; `PHPMailer::ENCRYPTION_SMTPS` encouraged
$mail->Port = 465; //TCP port to connect to, use 465 for `PHPMailer::ENCRYPTION_SMTPS` above
//Recipients
$mail->setFrom('support@mywebsite.com', 'Support - My Website');
$mail->addAddress($email, $name.' '.$lastName); //Add a recipient
$mail->addReplyTo('support@mywebsite.com', 'Support - My Website');
//Content
$mail->isHTML(true); //Set email format to HTML
$mail->Subject = 'Activate account - My Website';
$mail->Body = '
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<p>
Some text...
</p>
</body>
</html>
';
$mail->AltBody = "Some text...";
$mail->send();
//echo 'Message has been sent';
} catch (Exception $e) {
//echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
}
}
?>
Ps: Maybe this could be related to my domains don't having enough credibility due to beeing new and stuff... Maybe emails servers (gmail, outlook...) don't trust my domains for some reason?
I don't spam e-mails. These are e-mails for comfirming account when created, or some forms... But still all my websites e-mails gets flagged as spam.