0

I tried the code below but it is still sending to SPAM folder. Kindly help me to figure this out such that emails goes to INBOX only.

function sendEmail($content,$email,$phone){
  $headers = "Reply-To: Danuel <".$email.">\r\n";
  $headers .= "Return-Path:Danuel <".$email.">\r\n";
  $headers .= "From:Danuel <".$email.">\r\n"; 
  $headers .= "Organization:Danuel international\r\n";
  $headers .= "MIME-Version: 1.0\r\n";
  $headers .= "Content-type: text/plain; charset=iso-8859-1\r\n";
  $headers .= "X-Priority: 3\r\n";
  $headers .= "X-Mailer: PHP". phpversion() ."\r\n";
  $to ="xxxxxxxxx@gmail.com";
  $subject ="Number ".$phone." Banned";
  return mail($to, $subject, $content, $headers);
}

if(isset($_POST['send'])){
    $content='Hey';
    
    if(sendEmail($content,$_POST['email'],$_POST['phone'])==1){
       echo"<small><font color=green>Sent</font></small>";
    }else{
       echo"<small><font color=red>Failed</font></small>";
    }
}
James Z
  • 12,209
  • 10
  • 24
  • 44
  • I recommend you to use this package for mail https://github.com/PHPMailer/PHPMailer and use a SMTP server – executable Jan 02 '23 at 11:00
  • Does this answer your question? [How do you make sure email you send programmatically is not automatically marked as spam?](https://stackoverflow.com/questions/371/how-do-you-make-sure-email-you-send-programmatically-is-not-automatically-marked) – Chris Haas Jan 02 '23 at 14:12

0 Answers0