#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    1
    Rep Power
    0

    PHP Email Form - Email not sending


    Hi,

    I am new to PHP and I am trying to get PHP to send the contents of my form to my email address.

    Unfortunatly, I do not receieve the email, I have done some research, and I feel it may be due to the fact I have not defiend the mail server? Again, I am very new to this and the forums which had similar posts to mine, I struggled to understand.

    Here is my PHP code:

    PHP Code:
    <?PHP
    /*Subject and Email Validation */

        
    $emailSubject 'Woodingdean Dry Cleaners Enquiry';
        
    $webMaster 'navrajpanesar91@gmail.com';
        
    /* Gathering Data Variables */

        
    $titleField $_POST['title'];
        
    $nameField $_POST['name'];
        
    $emailField $_POST['email'];
        
    $telephoneField $_POST ['telephone'];
        
    $messageField $_POST ['message'];
        
    $body "
    <br><hr><br>
    Title: 
    $titleField<br>
    Name: 
    $nameField<br>
    Email: 
    $emailField<br>
    Telephone: 
    $telephoneField<br>
    Message: 
    $messageField<br>
    "
    ;
        
    $headers "From: $emailField\r\n";
        
    $headers .= "Content-type: text/html\r\n";
        
    $success mail("navrajpanesar91@gmail.com"$emailSubject$body$headers);
        
    /* Results rendered as HTML */

    $theResults "
    <html>
    <head>
    <title>Woodingdean Dry Cleaners</title>
    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">
    <style type=\"text/css\">
    <!--
    body {
        background-color: #f1f1f1;
        font-family: Verdana, Arial, Helvetica, sans-serif;
        font-size: 12px;
        font-style: normal;
        line-height: normal;
        font-weight: normal;
        color: #666666;
        text-decoration: none;
    }
    -->
    </style>
    </head>
    <div>
      <div align=\"left\">Your enquiry has been recieved. We will get back to you as soon as we can.</div>
    </div>
    </body>
    </html>

    "
    ;
    echo 
    $theResults;
    ?>
    Please could you kindly advise on what additions or corrections I need to make in order to get the contents of the form to me sent to my email address.

    Thanks in advance,
    Nav
  2. #2
  3. A Change of Season
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2004
    Location
    Next Door
    Posts
    2,650
    Rep Power
    171
    Originally Posted by NavrajPanesar
    Hi,

    I am new to PHP and I am trying to get PHP to send the contents of my form to my email address.

    Unfortunatly, I do not receieve the email, I have done some research, and I feel it may be due to the fact I have not defiend the mail server? Again, I am very new to this and the forums which had similar posts to mine, I struggled to understand.

    Here is my PHP code:

    PHP Code:
    <?PHP
    /*Subject and Email Validation */

        
    $emailSubject 'Woodingdean Dry Cleaners Enquiry';
        
    $webMaster 'navrajpanesar91@gmail.com';
        
    /* Gathering Data Variables */

        
    $titleField $_POST['title'];
        
    $nameField $_POST['name'];
        
    $emailField $_POST['email'];
        
    $telephoneField $_POST ['telephone'];
        
    $messageField $_POST ['message'];
        
    $body "
    <br><hr><br>
    Title: 
    $titleField<br>
    Name: 
    $nameField<br>
    Email: 
    $emailField<br>
    Telephone: 
    $telephoneField<br>
    Message: 
    $messageField<br>
    "
    ;
        
    $headers "From: $emailField\r\n";
        
    $headers .= "Content-type: text/html\r\n";
        
    $success mail("navrajpanesar91@gmail.com"$emailSubject$body$headers);
        
    /* Results rendered as HTML */

    $theResults "
    <html>
    <head>
    <title>Woodingdean Dry Cleaners</title>
    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">
    <style type=\"text/css\">
    <!--
    body {
        background-color: #f1f1f1;
        font-family: Verdana, Arial, Helvetica, sans-serif;
        font-size: 12px;
        font-style: normal;
        line-height: normal;
        font-weight: normal;
        color: #666666;
        text-decoration: none;
    }
    -->
    </style>
    </head>
    <div>
      <div align=\"left\">Your enquiry has been recieved. We will get back to you as soon as we can.</div>
    </div>
    </body>
    </html>

    "
    ;
    echo 
    $theResults;
    ?>
    Please could you kindly advise on what additions or corrections I need to make in order to get the contents of the form to me sent to my email address.

    Thanks in advance,
    Nav
    First use <?php instead of <?PHP , use phpmailer, eat your vegetable.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 2003
    Posts
    3,336
    Rep Power
    594
    PHP mail depends on 'sendmail'. Do you even have a mail server installed? If not you probably need to use PHPMailer which allows for an external mail server.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.

IMN logo majestic logo threadwatch logo seochat tools logo