0

The situation:

Writing a function in php with PHPMailer for sending account activation mails for a website.

The problem:

All my mails goes straight into the spam folder instead of inbox. Only gmail-adresses recieve my mails correctly.

My code:

<?php 
 /********************************************************************************************************************************
File:   sendmail.php
Author: Burtscher Florian
Date:   02.02.2017
Description:
    This file contains the sendmail functions for mailing noreply messages to EmailClients.
***************************************************************************************************************************/

require 'PHPMailer-master/PHPMailerAutoload.php';


$result = sendmail('asdf','asdf','asdf','asdf');

if(!$result){
   echo $result;
}


function sendmail($to,$subject,$message,$name){
  $mail = new PHPMailer;

  //$mail->SMTPDebug = 3;

  $mail->isSMTP();    // Set mailer to use SMTP
  $mail->Host = 'smtp.world4you.com';                //'smtp1.example.com;smtp2.example.com';      // Specifay main and backup SMTP server 
  $mail->SMTPAuth = true;                                                                    // Enable SMTP authentication
  $mail->Username = 'activation@scritex.com';
  $mail->Password = '*************';
  $mail->SMTPSecure = 'tls';
  $mail->Port = 587;                                                                   // TCP port to connect

  $mail->setFrom('activation@scritex.com', 'Activation');
  $mail->addAddress('mytestmail1111@dkimvalidator.com', 'Florian Burtscher');         // Add a recipient
  $mail->addReplyTo('activation@scritex.com', 'Office');                              // Add Reply To

  $mail->isHTML(true);

  $mail->Subject = 'Here is a 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->DKIM_domain = 'scritex.com';
  $mail->DKIM_private = '.htkeyprivate';
  $mail->DKIM_selector = 'dkim11';
  $mail->DKIM_passphrase = '1486107933';

  if(!$mail->send()){
    return $mail->ErrorInfo;
  }else{
    return true;
  }
}
?>

Result:

Find result here

I don´t have any idea what to do. Anyone who knows this problem?

All my mails goes at hotmail, outlook, yahoo, gmx, aon, msn to spam!

Shanu k k
  • 1,235
  • 2
  • 18
  • 43

1 Answers1

0

The sender service domain is blacklisted. Try using another smtp service. If that does not help, the domain that you are using (scritex.com) may be blacklisted. From there there are 2 possible solutions: 1. whitelist your domain (there are several services that do this but it is a lengthy and annoying process). 2. Use another domain

Auris
  • 1,309
  • 1
  • 9
  • 18