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

    php form not sending email

    Hi there i'm creating a web form using a php process page. the form sends the information to the process page but then after that we are not receiving the emails, i can't see what i've done wrong and would appreciate someone taking a look and seeing if they can see anything wrong,

    thanks v much

    Code below

    PHP Code:
    <?php 
    $errors 
    '';
    $myemail 'accounts@adlantic.ie';//<-----Put Your email address here.
    if(empty($_POST['Name'])  || 
       empty(
    $_POST['email']) ||
       empty(
    $_POST['phone']) ||  
       empty(
    $_POST['message']))
    {
        
    $errors .= "\n Error: all fields are required";
    }

    $name $_POST['Name']; 
    $email_address $_POST['email'];
    $phone $_POST['phone'];
    $message $_POST['message']; 

    if (!
    preg_match(
    "/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i"
    $email_address))
    {
        
    $errors .= "\n Error: Invalid email address";
    }

    if( empty(
    $errors))
    {
        
    $to $myemail
        
    $email_subject "Website Message from $name";
        
    $email_body "You have received a new message. ".
        
    " Here are the details:\n Name: $name \n Phone: $phone \n Email: $email_address \n Message \n $message"
        
        
    $headers "From: $myemail\n"
        
    $headers .= "Reply-To: $email_address";
        
        
    mail($to,$email_subject,$email_body,$headers);
        
    //redirect to the 'thank you' page
        
    header('Location: thankyou.php');

    ?>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
    <html>
    <head>
        <title>Contact form handler</title>
    </head>

    <body>
    <!-- This page is displayed only if there is some error -->
    <?php
    echo nl2br($errors);
    ?>


    </body>
    </html>

    link to page : http://www.irishdesigngroup.com/adlantic/

  • #2
    Regular Coder patryk's Avatar
    Join Date
    Oct 2012
    Location
    /dev/couch
    Posts
    398
    Thanks
    2
    Thanked 64 Times in 64 Posts
    try replacing mail($to,$email_subject,$email_body,$headers);
    with mail($to,$email_subject,$email_body);

    some servers don't like changing headers. especially "From:"
    also if you have some cheap hosting, then email might take really LONG time to arrive
    Last edited by patryk; 04-17-2013 at 07:14 PM.

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

  • Users who have thanked patryk for this post:

    MsKazza1 (04-17-2013)

  • #3
    New Coder
    Join Date
    Apr 2013
    Posts
    13
    Thanks
    2
    Thanked 0 Times in 0 Posts
    thank you perfect


  •  

    Posting Permissions

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