0

So, having used a template to create a simple company website, I included the "contact us" php, called "form.php" (code below).

When the form is completed, and the "Send" button is pressed, the response from the site is "Email has been sent". The problem is that nothing ever arrives!

I've been in touch with GoDaddy, who say that everything is good on their end, but they will not look at the code of my php. They uploaded a test php onto my site, and sent emails that were successfully received.

I'm completely lost on this, and cannot seem to see the issue, so any help would be greatly appreciated.

CODE>>>>>

<?php

$mail->SMTPDebug = 0;

$mail->Host = 'localhost';

$mail->Port = 25;

$mail->ssl = false;

$mail->authentication = false;


$to = 'steev@myemail.com';
$subject = 'Website Enquiry';
$from = $_POST['email'];
$headers = 'From: (mywebsite.net)' . "\r\n" . 'Content-type: text/html; charset=utf-8';
$message = '
<html>
    <head>
        <title>website Contact Form</title>
    </head>
    <body>
        <h3>Name: <span style="font-weight: normal;">' . $_POST['name'] . '</span></h3>
        <h3>Email: <span style="font-weight: normal;">' . $_POST['email'] . '</span></h3>
        <div>
            <h3 style="margin-bottom: 5px;">Comment:</h3>
            <div>' . $_POST['comment'] . '</div>
        </div>
    </body>
</html>';

if (!empty($_POST['name']) && !empty($_POST['email']) && !empty($_POST['comment'])) {
    if (filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
        mail($to, $subject, $message, $headers) or die('<span class="text-danger">Error sending Mail</span>');
        echo '<span class="text-success send-true">Your email was sent!</span>';
    }
} else {
    echo '<span class="text-danger">All fields must be filled!</span>';
}
?>
  • 1
    `From:` expects an email address, not a website. – Funk Forty Niner Aug 21 '17 at 11:34
  • 1
    however, you seem to be mixing phpmailer code with php's `mail()`. – Funk Forty Niner Aug 21 '17 at 11:35
  • Please read the [PHPMailer documentation](https://github.com/PHPMailer/PHPMailer/wiki/SMTP-Debugging). what does your PHP `error_log` say? What does your `PHPMailer Debug output` say? Please at least try and solve your own problems before throwing the at StackOverflow. Cheers – Martin Aug 21 '17 at 11:39
  • I think `$to = 'steev@myemail.com'; $from = $_POST['email'];` should be the other way around. – AutoTester213 Aug 21 '17 at 11:42
  • Hi Guys many thanks for the help, I have resolved the issue. Believe it or not, the problem was the the subject line "Website Enquiry" is being overused on GoDaddy, and was therefore marked as "BAD" on the error log. I changed that, to something a little less used, and all is working ok now! – Steev Jones Aug 22 '17 at 13:11

0 Answers0