0

Context: I'm just a front-end developer with very little php experience, our back-end guy left and I'm trying my best to fix stuff like this - so treat me like a beginner please!

Our client isn't receiving emails from their website contact form. However, when we set addAddress to my email, or even the client's alternate email (different domain), it is received fine.

require 'phpmailer/PHPMailerAutoload.php';

$mail = new PHPMailer(); // create a new object
$mail->IsSMTP(); // enable SMTP
$mail->SMTPDebug = 0; // debugging: 1 = errors and messages, 2 = messages only
$mail->SMTPAuth = true; // authentication enabled
$mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for Gmail
$mail->Host = "mail3.gridhost.co.uk";
$mail->Port = 465; // or 587
$mail->IsHTML(true);
$mail->Username = "username@ourcompany.co.uk";
$mail->Password = "******";
$mail->SetFrom("from@ourcompany.co.uk");

//Set who the message is to be sent to
$mail->addAddress('client@client.com', 'Client Name');
$mail->addAddress('client@client-alt.com', 'Client Alt Name');
$mail->addAddress('me@ourcompany.co.uk', 'My Name');

//Set the subject line
$mail->Subject = 'Contact Form Submission';

$mail->msgHTML($message);

//send the message, check for errors
if (!$mail->send()) {
            $data['success'] = false;
            $data['errors']  = $errors;
} else {
        $data['success'] = true;
        $data['message'] = 'Thank you - a member of our team will be in touch.';
}

    echo json_encode($data);

In the above code "client@client.com" does not receive any emails - client@client-alt.com, and me@ourcompany.co.uk do receive the emails.

When setting SMTPDebug to 1 or 2, I get the message "a problem has occurred" in the browser.

Unfortunately I am at a loss of what it could be, likely due to my lack of understanding of the whole thing. Hopefully someone here can give me a hand in understanding where the problem could be.

Mr DC
  • 33
  • 5
  • 2
    If other e-mail accounts are getting the e-mails, it's not a problem with the code. – Jonnix Nov 09 '16 at 16:50
  • TL;DR - You're going to have to have your host check their logs and configs. PHP can only tell you what the mail server responds with – Machavity Nov 09 '16 at 16:57

0 Answers0