0

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.

Soulss
  • 171
  • 1
  • 12
  • 1
    Try to send email to this website: https://www.mail-tester.com/ It shows all issues with your mail structure and server configuration. – Robert Dec 16 '21 at 07:01
  • 2
    TLDR: Did you add a SPF record that allows the (SMTP) servers of hostinger to send e-mails in behalf your domain? – DarkBee Dec 16 '21 at 07:07
  • 1
    [Reading the docs](https://github.com/PHPMailer/PHPMailer/wiki/Improving-delivery-rates,-avoiding-spam-filters) might help. – Synchro Dec 16 '21 at 08:22
  • @DarkBee Yes, SPF is already configured, testing with mail-tester.com shows that. – Soulss Dec 17 '21 at 17:17
  • @Robert I got a score of 7.5/10. The only thing lowering my score is this PYZOR_CHECK, apparently i'm listed there, i'll look more into this pyzor thing... – Soulss Dec 17 '21 at 17:18

0 Answers0