Grow your CSS skills. Land your dream job.

Contact Form not working on windows server

  • # September 29, 2009 at 4:14 pm

    I used Chris’ simple contact form for a website. It work absolutely fine on my server but when the client uploads it to their server, which is a windows server, its having problems. Instead of redirecting to the Success page, it redirects to the Error page but apparently the recipient is receiving emails. I don’t know why or how to stop it from redirecting to the error page, or to stop the error if that’s whats happening.

    EDIT: Correction, they are not receiving the emails, which means its not working at all.

    This is the code in the HTML

    Code:







    The contact engine

    Code:
    < ?php

    $EmailFrom = "JHREP Contact Form";
    $EmailTo = "mmendiola@jhrep.com";
    $Subject = "JH Real Estate Partners, Inc. Contact Form";
    $Name = Trim(stripslashes($_POST['Name']));
    $Email = Trim(stripslashes($_POST['Email']));
    $Message = Trim(stripslashes($_POST['Message']));

    // validation
    $validationOK=true;
    if (!$validationOK) {
    print "“;
    exit;
    }

    // prepare email body text
    $Body = “”;
    $Body .= “Name: “;
    $Body .= $Name;
    $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 ““;
    }
    else{
    print ““;
    }

    ?>

    Chris added a mod by Toni for windows server but I’m not sure if I’m using it correctly.

    Code:
    /* Modification by Toni for Windows servers */
    ini_set(“sendmail_from”, “me@mydomain.co.uk”);

    Should I put it in the contact engine at the end? Also, do I replace "me@mydomain.co.uk" with the Send To email?

    Please help!

    # September 29, 2009 at 7:17 pm

    Ok, I’m going to explain this a little more.

    I built a very simple website for a client using php includes, html, and css. Very simple. The form works fine on my development server.

    I gave it to the client to put on their own server. They’re using a Windows server. Everything except the contact form works. He’s a IT guy who knows all the server stuff but nothing about PHP or building websites. We’re trying to communicate to figure out the problem but we don’t know what the other is talking about most of the time. I asked if they use SMTP for their email and he said: "SMTP is not installed but we have an internal exchange server for our email. The websites that we have use this server to connect and send email through. I went ahead and install smtp anyways." Basically, I have no idea what this means and how to make it work.

    The code I showed in the above comment is exactly what’s on the website. I guess my main question is: What does he need to do to fix it on his end? Or what do I need to do on my end to fix it?

    Please help if you can! Thank you!

    # November 24, 2012 at 7:25 am

    Please did anyone resolve this issue, I am having the same problem

    # April 4, 2013 at 7:43 am

    Not sure if you have already sorted your issue, I have had the exact same problem and been scratching my head for days. I found a fix that works perfectly: (taken from another forum)

    Hi there,
    Fyi – I found the fix in the php manual, on a forum:

    Under windows there is a bug in php/mail
    See here: http://bugs.php.net/bug.php?id=28038
    this results in you being unable to send ‘From: Full Name ‘
    Workaround is:
    Set the following before calling the mail function:

    ini_set(‘sendmail_from’, ‘me@domain.com’);

    Hope this helps

    Mark

    # April 4, 2013 at 11:43 am

    Does the form have any validation? From its demo its seems no.

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".