php mail-form problem

  • Started
  • Last post
  • 2 Responses
  • smartK

    works fine actually, except that when I receive the email sent via the form the sender is "apache", while it should be sth like "$name" or so

  • jgjh1510

    This is what I used and it works great:

    <?php
    //mail elements
    $mail_to
    $mail_subject = "mydomain.com contact form";

    $mail_body = "mydomain.com Contact Form";
    $mail_body .= "First Name: $name ";
    $mail_body .= "Last Name: $name_last ";
    $mail_body .= "Organization: $organization ";
    $mail_body .= "Addresss: $address ";
    $mail_body .= "City: $city ";
    $mail_body .= "State: $state ";
    $mail_body .= "Zip Code: $zip ";
    $mail_body .= "Country: $country ";
    $mail_body .= "E-mail: $email ";
    $mail_body .= "Phone: $phone ";
    $mail_body .= "Fax: $fax ";
    $mail_body .= "Contact Department: $contact_department ";
    $mail_body .= "Message: $message ";

    $headers = "MIME-Version: 1.0
    ";
    $headers .= "Content-type: text/html; charset=iso-8859-1
    ";
    $headers .="From: $email - $name $name_last
    ";

    mail($mail_to, $mail_subject, $mail_body, $headers);
    ?>

  • dsmith70

    sounds like you aren't setting your $name var so Apache automatically sends it out from postmaster. This actually happened to me as well one time and I rectified the situation by making sure I had set my var for the sender.