treehouse : what would you like to learn today?
Web Design Web Development iOS Development

contact form

  • I have created a website with a contact form, but the email does't seem to be getting to certain email addresses, It gets through to mine and to the clients personal email but not the clients work email which is clientname@sullyco.co.uk and I can't work out why it doesn't go to that email address when normal emails go through fine

    the site is www.sullyco.co.uk if that helps

    Thanks
    Matt
  • I would definitely check the Apache error_log for messages and take it from there.
  • can we see contactengine.php?
  • Where's the Apache error_log?

    Yeah this is the contactenging.php with the email addresses changed

    <?php

    $EmailFrom = \"someone@sullyco.co.uk\";
    $EmailTo = \"someone@sullyco.co.uk\";
    $Subject = \"Enquiry from website\";
    $Name = Trim(stripslashes($_POST['Name']));
    $Tel = Trim(stripslashes($_POST['Tel']));
    $Email = Trim(stripslashes($_POST['Email']));
    $Message = Trim(stripslashes($_POST['Message']));

    // validation
    $validationOK=true;
    if (!$validationOK) {
    print \"<meta http-equiv=\\"refresh\\" content=\\"0;URL=error.htm\\">\";
    exit;
    }

    // prepare email body text
    $Body = \"\";
    $Body .= \"Name: \";
    $Body .= $Name;
    $Body .= \"\n\";
    $Body .= \"Tel: \";
    $Body .= $Tel;
    $Body .= \"\n\";
    $Body .= \"Email: \";
    $Body .= $Email;
    $Body .= \"\n\";
    $Body .= \"Message: \";
    $Body .= $Message;
    $Body .= \"\n\";

    // send email
    $success = mail($EmailTo, $Subject, $Body, \"From: <$EmailFrom>\");

    // redirect to success page
    if ($success){
    print \"<meta http-equiv=\\"refresh\\" content=\\"0;URL=contactthanks.php\\">\";
    }
    else{
    print \"<meta http-equiv=\\"refresh\\" content=\\"0;URL=error.htm\\">\";
    }
    ?>
  • Apache's error log depends on the host you are using. Either check via ftp for a logs directory, or in the directory your script is located, or if your host provides you with a control panel that might have a logs section.

    :mrgreen:
  • Hi,

    If it is not absolutely necessary I wouldn't define a From Email address. This causes some spam filters to go wild if the server is not set up correctly. For example, you could state the email came from whitehouse.gov and the mismatch between where you say it came from and where it actually does is a major warning sign for spam and phishing emails, which are treated as they should be by security software.