hi there I have a contact page. On my contact page when I click submit button an email should be gone to the corresponding email. But when I click submit button I am getting an error like this
HTTP Error 405.0 - Method Not Allowed
The page you are looking for cannot be displayed because an invalid method (HTTP verb) is being used.
here is my code. Please help me
 function sendmail() {
        //Get control's values to Variabls                
        var user = document.getElementById('txtname').value;//Country Name 
        var email1 = document.getElementById('txtemail').value;//Country Name 
        var phone1 = document.getElementById('txtphone').value;//Country Name 
        var course1 = document.getElementById('txtcourse').value;//Description
        var message1 = document.getElementById('txtmessage').value;//Corrections   
        var frommail = "gsevenitsolutions@gmail.com";//Corrections
        var pwd = "qmservice2017";//Corrections
        //check for validation
        var msg = "";
        if (user == '') {
            msg += "<li>user Name </li>";
        }
        if (email1 == '') {
            msg += "<li> enter email</li>";
        }
        if (phone1 == '') {
            msg1 += "Please Enter phonenumber";
        }
        if (course1 == '') {
            msg += "<li>Please Enter course</li>";
        }
        if (message1 == '') {
            msg += "Please Enter message";
        }
       
        if (msg.length == 0) {
            //Jquery ajax call to server side method
            $.ajax({
                type: "POST",
                dataType: "json",
                contentType: "application/json; charset=utf-8",
                //Url is the path of our web method (Page name/function name)
                // url: "addvisa.aspx/smstest",
                url: "mail.aspx/gmail",
                //Pass paramenters to the server side function
                data: "{'username':'" + user + "','email':'" + email1 + "','phone':'" + phone1 + "','course':'" + course1 + "','message':'" + message1 + "','frmmail':'" + frommail + "','frmpwd':'" + pwd + "'}",
                success: function (response)
                {
                    //Success or failure message e.g. Record saved or not saved successfully
                    if (response.d == true)
                    {
                        //Set message
                        $('#dvResult').text("Record saved successfully");
                        //Reset controls                          
                        $('#txtname').val('');
                        $('#txtemail').val('');
                        $('#txtphone').val('');
                        $('#txtcourse').val('');
                        $('#txtmessage').val('');
                    }
                    else {
                        $('#dvResult').text("Record could't be saved");
                    }
                    //Fade Out to disappear message after 6 seconds
                    $('#dvResult').fadeOut(6000);
                },
                error: function (xhr, textStatus, error) {
                    //Show error message(if occured)
                    $('#dvResult').text("Error: " + error);
                }
            });
        }
        else {
            //Validation failure message
            // $('#dvResult').html('');
            $('#dvResult').html(msg);
        }
        $('#dvResult').fadeIn();
    }
 
  [WebMethod]
        
        public static bool gmail(string username, string email, string phone, string course, string message, string frmmail, string frmpwd)
        {
            bool status; int retVal=1;
            string smsmatter = "";
            string mob="8714518818";
            try
            {
                using (MailMessage mm = new MailMessage(email,frmmail))
                {
                    mm.Subject = "contact mail";
                    mm.Body = "Name :" + username + "|| phone : " + phone + "||Subject :" + course + " || message:" + message;
                    mm.IsBodyHtml = false;
                    SmtpClient smtp = new SmtpClient();
                    smtp.Host = "smtp.gmail.com";
                    smtp.EnableSsl = true;
                    NetworkCredential NetworkCred = new NetworkCredential(frmmail, frmpwd);
                    smtp.UseDefaultCredentials = true;
                    smtp.Credentials = NetworkCred;
                    smtp.Port = 587;
                    smtp.Send(mm);
                    // ClientScript.RegisterStartupScript(GetType(), "alert", "alert('Email sent.');", true);
                }
            }
            catch
            {
                status = false;
            }
            finally
            {
                using (MailMessage mm1 = new MailMessage(frmmail,email))
                {
                    mm1.Subject = "TSQUARE CAD ACADEMY IRINJALKUDA";
                    mm1.Body = "Dear " + username + ", Thanks for contacting with us, Our team will contact asap.|| Best regards; ANTONY ||TSQUARE CAD ACADEMY IRINJALKUDA;||  info@tsquarecadacamy.com;|| www.tsquare.org.in||   9388226655 ";
                    //mm1.Body = "Name :" + username + "|| phone : " + phone + "||Subject :" + course + " || message:" + message;
                    mm1.IsBodyHtml = false;
                    SmtpClient smtp = new SmtpClient();
                    smtp.Host = "smtp.gmail.com";
                    smtp.EnableSsl = true;
                    NetworkCredential NetworkCred = new NetworkCredential(frmmail, frmpwd);
                    smtp.UseDefaultCredentials = true;
                    smtp.Credentials = NetworkCred;
                    smtp.Port = 587;
                    smtp.Send(mm1);
                    smsmatter = "Dear, Name :" + username + "|| phone : " + phone + "||Subject :" + course + " || message:" + message +" Thank You ."; ;
                    WebRequest request = HttpWebRequest.Create("http://138.128.21.170/api/send_transactional_sms.php?username=u103&msg_token=MCd3ON&sender_id=TSQIJK&message="+ smsmatter +"&mobile="+ mob +"");
                 
                }
                status = true;
            }
                                 
           
            return status;
        }