Search code examples
phpphpmailerhttp-status-code-409hostgator

409 Conflict with Hostgator


I am getting a 409 Conflict error after uploading files to Hostgator server. They initially said it was an issue with the nameserver, but that has since been resolved. Now they are saying that it's an issue with my code. I am trying to narrow down the possibilities, but I am getting frustrated.

I built this site using Docker. Here is the Dockerfile:

FROM php:7.4-apache
RUN docker-php-ext-install pdo pdo_mysql

Now I did notice that Hostgator is using PHP 8.3.6. If that is the problem, you can stop right here and let me know. I am leaning towards it not being the problem.

I'm using jQuery to grab the form data and sending to the PHP script like this:

$.post("process/contact.php", { cobj: cobj }, function(data) {
  if (data == "success") {
    toastr.success("good");
  } else {
    toastr.error("fail");
  }
});

The contact.php looks like this:

<?php
use phpmailer\PHPMailer\PHPMailer;
require_once '../phpmailer/PHPMailer.php';
require_once '../phpmailer/SMTP.php';
require_once '../phpmailer/Exception.php';

if(isset($_POST['cobj'])) {
  $value = $_POST['cobj'];
  
  $fullname = $value['fullname'];
  $email = strtoupper($value['email']);
  $phonenumber = $value['phonenumber'];
  $message = $value['message'];
  $date = date('Y-m-d H:i:s');

  $mail = new PHPMailer;
  $mail->SMTPDebug = 1;      
  $mail->isSMTP();                                        
  $mail->Host = 'smtp.mail.yahoo.com';                             
  $mail->SMTPAuth = true;  
  $mail->SMTPSecure = 'tls';                                                            
  $mail->Port = 587; 
  $mail->setFrom('xxxxxxxxx', 'Mailer');
  $mail->addAddress('yyyyyyyyyyy', 'Receiver');      
  $mail->addReplyTo('xxxxxxxxxxx', 'No Reply'); 

  $mail->SMTPOptions = array(
    'ssl' => array(
       'verify_peer' => false,
       'verify_peer_name' => false,
       'allow_self_signed' => true
      )
    );  
    $mail->isHTML(true);
    $mail->Username = "xxxxxxxxxx";
    $mail->Password = "password";
    
    $mail->Subject = 'Message';
    $mail->Body    = '<h3>You received a message.</h3>
                        <p>From: '.$fullname.'</p>
                        <p>Email: '.$email.'</p>
                        <p>Phone: '.$phonenumber.'</p>
                        <p>Message: '.$message.'</p>
                        <p>Sent on: '.$date.'</p>
                        <p>Please follow up.</p>';

    if(!$mail->send()) {
        echo 'Error';
    } else {
        echo 'Success';
    }        
}
?>

I probably didn't need to include all the code from contact.php but I did just in case.

I had commented everything out of the contact.php and was still getting the 409 conflict error.

It appears the PHP mailer version I'm using is 5. Not sure if that could be the problem.

Regardless, everything is working locally. How can I solve it on the live site?


Solution

  • I spoke with Hostgator multiple times. First they said it was a problem with the nameserver. When they made that adjustment, it still didn't work.

    Then they said it was a problem with the email account. When we made the adjustments, I still was getting the same error.

    Finally, after escalating the call, it turns out it was a "whitelisting" issue. Apparently, the form needed to be whitelisted. I am not sure why, but if you come across the same 409 conflict error, mention "whitelisting the form", and hopefully that will solve the problem.