Grow your CSS skills. Land your dream job.

Empty emails

  • # December 17, 2009 at 10:06 pm

    I use a simple contact form with the mail() function:

    Code:
    $name = $_POST["name"];
    $email = $_POST["email"];
    $findus = $_POST["hear"];
    $subject = $_POST["subject"];
    $body = $_POST["body"];

    $content = ”
    Name: $name

    Email: $email

    How did you hear about us?
    $findus

    Message:
    $body”;

    $send = mail( “clientsEmailAddress”, “$subject”, $content, “from: $email” );

    if($send)
    header(“location: confirm_contact.php”);
    else
    header(“location: error_contact.php”);

    however, my client is getting blank emails from what seems to be the web server. they have no subjects either, even though on my contact form that isn’t an option. The emails look like this:

    From: <clientsusername@p3nlh104.shr.prod.phx3.secureserver.net>
    Date: Thu, Dec 17, 2009 at 9:24 PM
    Subject:
    To: clientsemail@gmail.com

    Name:

    Email:

    How did you hear about us?

    Message:

    the DNS is prod.****.secureserver.net. I assumed the server was causing an issue so I called them and was told the issue was with my form and/or php.

    Anyone else ever see this issue?

    # December 21, 2009 at 11:14 am

    I can’t see exactly what the code is as its to small and i don’t want to have to copy and paste it somewhere else to read it.
    But at a brief glance i think your problem lies where your message is being assembled.
    I think you have
    $content = " Name: $Name rest off text… ";
    I think it should be,
    $content = " Name:".$Name." rest off text… ";
    Do you understand what i mean?

    # December 21, 2009 at 11:26 am

    When the form is filled out it works fine. These aren’t emails sent by people trying to contact the client it’s seems to come from his server.

    $name = $_POST["name"];
    $email = $_POST["email"];
    $findus = $_POST["hear"];
    $subject = $_POST["subject"];
    $body = $_POST["body"];

    $content = "
    Name: $name

    Email: $email

    How did you hear about us?
    $findus

    Message:
    $body";

    $send = mail( "clientsEmailAddress", "$subject", $content, "from: $email" );

    if($send)
    header("location: confirm_contact.php");
    else
    header("location: error_contact.php");

    All info is correct when you fill out the form. He’s just getting random blank emails that have the form elements from the body just no text or subject.

    # December 21, 2009 at 11:51 am

    Oh ok, i get you.
    Are these blank emails sent together when the form has been filled out, so the client recieves one filled out email and one blank, or do they receive them at completely random times?
    All that code looks fine to me…
    Whats your forms code?

    # December 21, 2009 at 12:00 pm

    sent at random times.

    the form is simple:

    fill in the boxes, press send, send posts to the contact.php file.

    # December 21, 2009 at 12:10 pm

    I have no idea whats causing it then, if i was you i would try and validate the data in the php file first.
    So try this,

    if ($_POST["name"] != "") {

    $name = $_POST["name"];
    $email = $_POST["email"];
    $findus = $_POST["hear"];
    $subject = $_POST["subject"];
    $body = $_POST["body"];

    $content = "
    Name: $name

    Email: $email

    How did you hear about us?
    $findus

    Message:
    $body";

    $send = mail( "clientsEmailAddress", "$subject", $content, "from: $email" );

    if($send)
    header("location: confirm_contact.php");
    else
    header("location: error_contact.php");

    }

    I typed that first line off the top of my head so you might need to check it.

    # December 21, 2009 at 12:46 pm

    I have an statement in there to check for missing name, subject, etc. I just left it out of the post since I thought it would be trivial to the issue.

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

You must be logged in to reply to this topic.

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