0

When i am submitting the php contact form in local xampp server showing 'We are unable to send email due to some technical problems. Please try again.' Pls help how to fix this error..

Here is my php code

<?php
session_start();
ini_set("display_errors",'0');//Display errors
if($_POST['submit'])
{
$key=substr($_SESSION['key'],0,5);
//echo "key---------->".$key;
$number = $_REQUEST['number'];
//echo "number---------->".$number;
if($number!=$key) {
$error="<left><font color=\"red\"><b>Invalid Enter Code !</b></font></left>";
}
else
{
    $to = "test@gmail.com";

            $html_msg = '
            <html>
                <head>
                    <title>test Services Enquiry Form</title>
</head>
     <body>

     <table width="0%" align="center" cellpadding="5" cellspacing="0" style="border:2px solid #2964B0;">
        <tr>
        <td colspan="3" align="center" bgcolor="#2763AF"><font color="#FFFFFF" size="3" face="Arial, Helvetica, sans-serif"><strong>test Services Enquiry Form</strong></font></td>
        </tr>
        <tr>
        <td align="right"><font size=2 color=322147 face=Arial, Helvetica, sans-serif><b>Name</b></font></td>
        <td><strong><font size=2 color=#2d557f face=verdena>:</font></strong></td>
        <td><font size=2 color=#000000 face=verdena>'.$_POST['txtName'].'</font></td>
        </tr>

        <tr>
        <td align="right"><font size=2 color=322147 face=Arial, Helvetica, sans-serif><b>Mobile</b></font></td>
        <td><strong><font size=2 color=#2d557f face=verdena>:</font></strong></td>
        <td><font size=2 color=#000000 face=verdena>'.$_POST['txtPhone'].'</font></td>
        </tr>

        <tr>
        <td align="right"><font size=2 color=322147 face=Arial, Helvetica, sans-serif><b>Email</b></font></td>
        <td><strong><font size=2 color=#2d557f face=verdena>:</font></strong></td>
        <td><font size=2 color=#000000 face=verdena>'.$_POST['txtEmail'].'</font></td>
        </tr>

        <tr>
        <td align="right"><font size=2 color=322147 face=Arial, Helvetica, sans-serif><b>Gross Income</b></font></td>
        <td><strong><font size=2 color=#2d557f face=verdena>:</font></strong></td>
        <td><font size=2 color=#000000 face=verdena>'.$_POST['txtIncome'].'</font></td>
        </tr>


        </table>
   </body>
                    </html>';

    ini_set ("sendmail_from", "test@gmail.com");
    ini_set("SMTP","localhost");
    $subject="test Services Form : ".$_POST['txtName'];
    $headers = 'MIME-Version: 1.0' . "\r\n";
    $headers .= "Content-type: text/html; charset=utf-8\r\n ";
    $message .="Content-Transfer-Encoding: 7bit \r\n";
    $message=$html_msg;
    $mailsent= mail($to,$subject,$message,$headers);

    if($mailsent)
    {

     /*header("location:thanks.html");*/

     echo "<script language=javascript>;window.location=\"index.php\";alert(\"Thanks for filling the form. We will get in touch with you soon. \");</script>";




     /* $msg="<font color='#E7B376'>Thanks for submitting our booking form.
<br>One of our representatives will get in touch with you soon.</font>";*/
    }

    else
    {
    $msg="<span style='color:red;'>We are unable to send email due to some technical problems. Please try again.</span>";

    }

}
}


?>

2 Answers2

0

You have to configure your php.ini with SMTP data of your e-mail.

See this tutorial at: http://planetghost.com/send-emails-localhost-xampp-wamp-php

Don't forget to restart the server after changes.

0

Ramakrishna i have found solution for your problem might be it will helps you

PHP : send mail in localhost

http://rajeshstutorials.blogspot.in/2012/04/how-to-set-up-smtp-server-on-localhost.html

Community
  • 1
  • 1
Nils
  • 11
  • 4