My website contact page intimating thankyou message but i didn't get mail

i have contact.aspx and contact.html pages only and not php. pls tell me a solution to receive the mail

Hi Jona, welcome to the forum

Sorry, but that is way too little information for anyone to possibly be able to help.

Please post the code involved (with any sensitive info removed)

<head>

<meta name="keywords" content="" />

<meta name="description" content=""  />

<meta http-equiv="content-type" content="text/html; charset=utf-8" />

<title></title>

<link href="css/style.css" rel="stylesheet" type="text/css" media="all" />

<link href="css/vistyle.css" rel="stylesheet" type="text/css" media="all" />

<meta name="viewport" content="width=device-width, initial-scale=1, maximum-

scale=1">

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<link href='http://fonts.googleapis.com/css?family=PT+Sans' rel='stylesheet' 

type='text/css'>

<script>

  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){

  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),

  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)

  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');



  ga('create', 'UA-54369646-1', 'auto');

  ga('send', 'pageview');



</script>

</head>

<body>

<div class="header">    

    <div class="wrap"> 

        <div class="header-top">



             <div class="col vispan_2_of_3" style="float:left;">

                <div class="">

                    <img src="" alt= "" />

                </div>

            </div>    

            

            <div class="col span_3_of_3 " style="float:left;">

                <img src="" />

            </div>   

                                      

            <div class="col span_3_of_3 " style="float:right;">    

                <div class="visible-all-devices header-text ">        

                <div class="textwidget">Corporate<br>

                    

                    Phone: +56577                   

                    <p>Email: <span><a 

href="mailto:someone@example.com">someone@example.com</a></span></p>

                </div>

                </div>

            </div>



            <div class="clear"></div> 

        </div>

    </div>    

</div>    

<!------ Slider ------------>

   <div class="about-banner">

      <div class="wrap">

           <div class="cssmenu">

                <ul>

                   <li><a 

href="index.html"><span>Home</span></a></li>

                   <li><a href="about.html"><span>About 

us</span></a></li>

                   <li><a 

href="products.html"><span>Products</span></a></li>

                   <li><a 

href="services.html"><span>Services</span></a></li>

                   <li class="active"><a 

href="contact.html"><span>Contact</span></a></li>
                   
                  

                  <div class="clear"></div>

               </ul> 

           </div>

      </div>

   </div>

        <!------End Slider ------------>

  <div class="main">

     <div class="wrap">

        <div class="section group">

                <div class="col span_2_of_3">

                  <div class="contact-form">

                      <h3>Contact Us</h3>

                                        <?php

                                        $action=$_REQUEST['action'];

                                        if ($action=="")    /* display the 

contact form */

                                            {

                                        ?>

                        <form method="post" action="" 

enctype="multipart/form-data">

                            <div>

                                

<span><label>Name</label></span>

                                                        <span></span><input 

type="hidden" name="action" value="submit"></span>

                                <span><input 

name="userName" type="text" class="textbox"></span>

                            </div>

                            <div>

                                <span><label>E-

Mail</label></span>

                                <span><input 

name="userEmail" type="text" class="textbox"></span>

                            </div>

                            <div>

                                 

<span><label>Mobile</label></span>

                                <span><input 

name="userPhone" type="text" class="textbox"></span>

                            </div>

                            <div>

                                

<span><label>Subject</label></span>

                                <span><textarea 

name="userMsg"> </textarea></span>

                            </div>

                           <div>

                                   <input 

type="submit" name="submit" value="Send email" class="btn btn-primary btn1">

                          </div>

                        </form>

                                        <?php

                                        } 

                                    else                /* send the submitted 

data */

                                        {

                                        $name=$_REQUEST['userName'];

                                        $email=$_REQUEST['userEmail'];

                                        $message=$_REQUEST['userMsg'];

                                        if (($name=="")||($email=="")||

($message==""))

                                            {

                                            echo "All fields are required";

                                            }

                                        else{        

                                            $from="From: $email";

                                            $subject="Message sent using your 

contact form";

                                            mail("someone@example.com", $subject, 

$message, $from);

                                            echo "Email sent!";

                                            }

                                        }  

                                    ?>                                            

                  </div>

                  </div>

                <div class="col span_1_of_3">

                    <div class="contact_info">

                         <h3>Find Us Here</h3>

                              <div class="map"><iframe src="" 

width="400" height="300" frameborder="0" style="border:0"></iframe>            

                                              

  

                                
                               <br><small>
 <a href="" style="color:#666;text-align:left;font-size:12px" 

target="_blank">View Larger Map</a></small>                        

      

                              </div>

                      </div>

                     <div class="company_address">

                         <h3>Company Information :</h3>

                                <p> Street</p>

                                   <p></p>

                                   <p></p>

                           <p>Phone:</p>

                          <p>Email: <span><a 

href="mailto:someone@example.com">someone@example.com</a></span></p>

                   </div>

                 </div>

                   <div class="clear"></div>

              </div>

     </div>

    </div>

    <div class="footer">

        <div class="wrap">

            <div class="footer-text">

                <div class="copy">

                                    <p align="justify"> PRODUCTS: 

                                          
                                        </p>

                </div>

                                <br>

                <div class="copy">

                    <p> Copyright.</a></p>

                </div>

            </div>    

        </div>

    </div>

</body>

</html>

This is html page

this is contact.aspx page

<%@ Page Language="C#" %>

<%@ Import Namespace="System.Net" %>
<%@ Import Namespace="System.Net.Mail" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Web.Script.Serialization" %>
<!-- code section -->
<script runat="server">
    public bool Validate()
    {
        string Response = Request["g-recaptcha-response"];//Getting Response 

String Append to Post Method
        bool Valid = false;
        //Request to Google Server
        HttpWebRequest req = (HttpWebRequest)WebRequest.Create
        (" https://www.google.com/recaptcha/api/siteverify?response=" + 

Response);
        try
        {
            //Google recaptcha Response
            using (WebResponse wResponse = req.GetResponse())
            {

                using (StreamReader readStream = new StreamReader

(wResponse.GetResponseStream()))
                {
                    string jsonResponse = readStream.ReadToEnd();

                    JavaScriptSerializer js = new JavaScriptSerializer();
                    MyObject data = js.Deserialize<MyObject>(jsonResponse);// 

Deserialize Json

                    Valid = Convert.ToBoolean(data.success);
                }
            }

            return Valid;
        }
        catch (WebException ex)
        {
            throw ex;
        }
    }

    protected void btSendMail_Click(object sender, EventArgs e)
    {
        if (!Validate())
        {
            lblMsg.InnerText = "Please enter valid captcha text";
            lblMsg.Style.Add("color", "red");
            return;
        }

        try
        {
            string contactMsg = composeMsg();
            
            MailMessage mailMsg = new MailMessage();
            mailMsg.To.Add("someone@example.com");
            mailMsg.From = new MailAddress("someone@example.com");
            //Set subject and body
            mailMsg.Subject = "Customer contact through website";
            mailMsg.Body = contactMsg;
            //Set mail server and port
            //SmtpClient smtpClient = new SmtpClient("smtp.gmail.com", 465);
            SmtpClient smtpClient = new SmtpClient("ip.ad.dre.ss");
            smtpClient.UseDefaultCredentials = true;
            //NetworkCredential netCre = new NetworkCredential

("someone@example.com", "");
            //smtpClient.Credentials = netCre;        
            //smtpClient.EnableSsl = true;
            smtpClient.Send(mailMsg);
            lblMsg.Style.Add("color", "green");
            lblMsg.InnerText = "Thank you for contacting . We will get back to 

you shortly.";
            //lblMsg.InnerText = contactMsg;
        }
        catch (Exception ex)
        {
            lblMsg.Style.Add("color", "red");
            lblMsg.InnerText = "Service is not available now, We apologies for 

the inconvenience caused. Pleae contact us through our email address 

someone@example.com";
        }
    }

    private string composeMsg()
    {
        StringBuilder msg = new StringBuilder(string.Empty);
        
        msg.Append("Dear Team, " );
        msg.AppendLine();
        msg.AppendLine();
        msg.Append("Name: " + Request.Form["userName"]);
        msg.AppendLine(); 
        msg.AppendLine();
        msg.Append("Email: " + Request.Form["userEmail"]);
        msg.AppendLine();
        msg.AppendLine();
        msg.Append("Phone: " + Request.Form["userPhone"]);
        msg.AppendLine();
        msg.AppendLine();
        msg.Append("Message: " + Request.Form["userMsg"]);
        msg.AppendLine();
        msg.AppendLine();
        
        return msg.ToString();
        
    }
    
    public class MyObject
    {
        public string success { get; set; }
    }
</script>

<html>
<head>
<meta name="keywords" content="yu" />

<meta name="description" content="10K "
        <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <!-- Go to www.addthis.com/dashboard to customize your tools -->
    <script type="text/javascript" 

src="//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-54e54c9f4eda3fcd" 

async="async"></script>
    <LINK REL="SHORTCUT ICON" HREF="images/vilo.jpg">

    <title></title>
    <link href="css/style.css" rel="stylesheet" type="text/css" media="all" />
    <link href="css/vistyle.css" rel="stylesheet" type="text/css" media="all" />
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-

scale=1">

But you also have PHP code in there!

I’m confused. It looks like 2 unrelated code examples, one ASP, one PHP

I have never seen both used together. I suppose it might be possible. But if it is, how to do so is beyond my skill level.

For the code example with the PHP code:
Assuming this is an ASP server without PHP that renders the page, the browser will see the PHP code as an unrecognized tag and the form will be shown but the PHP code will never happen. .

For the code example with the ASP code:
Both the Send and the “thank you” are in a try{} so I would think since it isn’t catching an exception that part is working OK

Color me confuzzled

1 Like

I’ll color you, if you’ll colour me! :slight_smile:

2 Likes

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.