Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Jan 2013
    Thanked 0 Times in 0 Posts

    php contact form works but dont recieve email

    For some reason the script works and gives me the success message but I never receive the email.

    <div id="form">
    <span>Yes, I Want To Sleep Better!</span>
    <form name="contactform" method="post" action="email_form.php">
    <label for="fname">First Name: </label> 
    <input type="text" name="fname"><br>
    <label for="lname">Last Name: </label> 
    <input type="text" name="lname"><br>
    <label for="address">Address: </label> 
    <input type="text" name="address"><br>
    <label for "city">City: </label> 
    <input type="text" name="city"><br>
    <label for="state">State: </label> 
    <select name="state" size="1">
    <option value="Alabama">Alabama</option>
    <option value="Alaska">Alaska</option>
    <option value="Arizona">Arizona</option>
    <option value="Arkansas">Arkansas</option>
    <option value="California">California</option>
    <option value="Colorado">Colorado</option>
    <option value="Connecticut">Connecticut</option>
    <option value="Delaware">Delaware</option>
    <option value="Florida">Florida</option>
    <option value="Georgia">Georgia</option>
    <option value="Hawaii">Hawaii</option>
    <option value="Idaho">Idaho</option>
    <option value="Illinois">Illinois</option>
    <option value="Indiana">Indiana</option>
    <option value="Iowa">Iowa</option>
    <option value="Kansas">Kansas</option>
    <option value="Kentucky">Kentucky</option>
    <option value="Louisiana">Louisiana</option>
    <option value="Maine">Maine</option>
    <option value="Maryland">Maryland</option>
    <option value="Massachusetts">Massachusetts</option>
    <option value="Michigan">Michigan</option>
    <option value="Minnesota">Minnesota</option>
    <option value="Mississippi">Mississippi</option>
    <option value="Missouri">Missouri</option>
    <option value="Montana">Montana</option>
    <option value="Nebraska">Nebraska</option>
    <option value="Nevada">Nevada</option>
    <option value="New Hampshire">New Hampshire</option>
    <option value="New Jersey">New Jersey</option>
    <option value="New Mexico">New Mexico</option>
    <option value="New York">New York</option>
    <option value="North Carolina">North Carolina</option>
    <option value="North Dakota">North Dakota</option>
    <option value="Ohio">Ohio</option>
    <option value="Oklahoma">Oklahoma</option>
    <option value="Oregon">Oregon</option>
    <option value="Pennsylvania">Pennsylvania</option>
    <option value="Rhode Island">Rhode Island</option>
    <option value="South Carolina">South Carolina</option>
    <option value="South Dakota">South Dakota</option>
    <option value="Tennessee">Tennessee</option>
    <option value="Texas">Texas</option>
    <option value="Utah">Utah</option>
    <option value="Vermont">Vermont</option>
    <option value="Virginia">Virginia</option>
    <option value="Washington">Washington</option>
    <option value="West Virginia">West Virginia</option>
    <option value="Wisconsin">Wisconsin</option>
    <option value="Wyoming">Wyoming</option>
    <label for ="zip">Zip Code: </label> 
    <input type="text" name="zipcode"><br>
    <label for="phone">Phone: </label> 
    <input type="text" name="phone"><br>
    <label for="email">Email: </label> 
    <input type="text" name="email"><br>
    <!-- <textarea name="comments" rows="15" cols="20"></textarea> -->
    <label style="font-size: .7em; padding-top: 3px;">I agree to the terms and conditions:</label> 
    <input type="radio" name="yes" value="yes" />
    <p><strong>Why ApneaRx</strong><br /><br />
    ApneaRx offers an affordable, easy-to-use way to provide sleep apnea patients with more treatment options. It can be micro-adjusted to help determine their candidacy for sleep apnea treatments — custom oral appliances, combo CPAP therapies or continued ApneaRx usage. </p>
    <input id="submit" type="submit" value="Submit">
    </div> <!-- close form -->
    PHP Code:
    if(isset($_POST['email'])) {
    $email_to "andrew@apolismedical.com, ahaberman25@gmail.com";
    $email_subject "Feedback from PPHA";
    died($error) {
    // your error code can go here
    echo "We are very sorry, but there were error(s) found with the form you submitted. ";
    "These errors appear below.<br /><br />";
    $error."<br /><br />";
    "Please go back and fix these errors.<br /><br />";
    // validation expected data exists
    if(!isset($_POST['fname']) ||
    $_POST['lname']) ||
    $_POST['email']) ||
    $_POST['phone'])) {
    died('We are sorry, but there appears to be a problem with the form you submitted.');      
    $fname $_POST['fname']; // required
    $lname $_POST['lname']; // required
    $email $_POST['email']; // required
    $phone $_POST['phone']; // not required
    $error_message "";
    $email_exp '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
    preg_match($email_exp,$email)) {
    $error_message .= 'The Email Address you entered does not appear to be valid.<br />';
    $string_exp "/^[A-Za-z .'-]+$/";
    preg_match($string_exp,$fname)) {
    $error_message .= 'The First Name you entered does not appear to be valid.<br />';
    preg_match($string_exp,$lname)) {
    $error_message .= 'The Last Name you entered does not appear to be valid.<br />';
    strlen($error_message) > 0) {
    $email_message "Form details below.\n\n";
    clean_string($string) {
    $bad = array("content-type","bcc:","to:","cc:","href");
    $email_message .= "First Name: ".clean_string($fname)."\n";
    $email_message .= "Last Name: ".clean_string($lname)."\n";
    $email_message .= "Email: ".clean_string($email)."\n";
    $email_message .= "Telephone: ".clean_string($phone)."\n";
    // create email headers
    $headers 'From: '.$email_from."\r\n".
    'Reply-To: '.$email_from."\r\n" .
    'X-Mailer: PHP/' phpversion();
    <!-- include your own success html here -->
    Thank you for contacting us. We will be in touch with you very soon.
    I have used this script before and it has worked until now for some reason.

    Thank you for any help.

  2. #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Saskatoon, Saskatchewan
    Thanked 2,668 Times in 2,637 Posts
    You haven't done anything to verify that mail has been queued. This suppresses any errors from mail, and then simply tells you it was successful. Change mail to detect if a queue was performed:
    PHP Code:
    if (!mail($email_to$email_subject$email_message$headers))
    // do something to indicate a queue failure.

    Still won't guarantee anything, but so long as that pulls up successful the problem isn't with PHP.

    Quote Originally Posted by ahaberman25 View Post
    I have used this script before and it has worked until now for some reason.
    This indicates something else has changed. Check your error logs for both sendmail and PHP.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

  3. #3
    Regular Coder patryk's Avatar
    Join Date
    Oct 2012
    Thanked 64 Times in 64 Posts
    try like that:
    PHP Code:
    // create email headers

    "Real Programmers can write assembly code in any language" - Larry Wall

  4. Users who have thanked patryk for this post:

    ahaberman25 (04-18-2013)

  5. #4
    New Coder
    Join Date
    Jan 2013
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by patryk View Post
    try like that:
    PHP Code:
    // create email headers
    cant believe I forgot this THANK YOU!


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts