简体   繁体   English

当我尝试使用 emailjs 时出现 thsi 错误:Uncaught ReferenceError: sendMail is not defined emailjs

[英]im getting thsi error when i try to use emailjs: Uncaught ReferenceError: sendMail is not defined emailjs

i have a problem with the send email im using emailjs to send email but its not working note its the first time im using javascript to send email i tried once with python and i manged with the help of stackover flow of course i have a problem with the send email im using emailjs to send email but its not working note its the first time im using javascript to send email i tried once with python and i manged with the help of stackover flow of course

js js

function sendMail(params){
        var tempparams ={
            from_name:document.getElementById("InputName").value,
            last_name:document.getElementById("InputLastname").value,
            pick_up:document.getElementById("shippingOption1").value,
            delivery:document.getElementById("shippingOption2").value,
            addressone:document.getElementById("address").value,
            addresstwo:document.getElementById("address2").value,
            total:document.getElementById("total")
            

            
        }
        emailjs.send(service_mvduipb,template_8cr649h,tempParams)
        .then(function(res){
              console.log("success",res.status)
              })
    }
    
}

html html

 <section id="sectionone"
form method = "post"         class ="hidesection"  >
    
     <div class="col-sm-6 col-lg-6 mb-3">
                    <div class="row">
                        <div class="col-md-12 col-lg-12">
                            <table class="table">
                                <thead>
                                <tr>
                                    <th>Shipping Method</th>
                                    <th>Name</th>
                                    <th>Adress</th>
                                                                    </tr>
                            </thead>
                                
                                <tbody>
                                <tr>
                                    <td>
                                        
                                    <div class="custom-control custom-radio">
                                        <input id="shippingOption1" name="shipping-option" class="custom-control-input" checked="checked" type="radio">
                                        <label class="custom-control-label" for="shippingOption1">Pickup</label> <span class="float-right font-weight-bold">FREE</span> </div>
                                            <div class="ml-4 mb-2 small">All week</div></td>
                                <td>
                                    <div class="form-group col-md-6">
                                <label for="InputName" class="mb-0">First Name</label>
                                <input type="text" class="form-control" id="InputName" placeholder="First Name"> </div></td>
                                <td> <div class="mb-3">
                                <label for="address">Address *</label>
                                <input type="text" class="form-control" id="address" placeholder="" required>
                                <div class="invalid-feedback"> Please enter your shipping address. </div>
                            </div></td></tr>
                                    
                                        <tr>
                                            <td>
                                        <div class="custom-control custom-radio">
                                        <input id="shippingOption2" name="shipping-option" class="custom-control-input" type="radio">
                                        <label class="custom-control-label" for="shippingOption2">Express Delivery</label> <span class="float-right font-weight-bold">Free (Only To Rabat Area)</span> </div>
                                    <div class="ml-4 mb-2 small">Monday To sunday Exept Tuesday</div>
                                </td><td><div class="form-group col-md-6">
                                <label for="InputLastname" class="mb-0">Last Name</label>
                                <input type="text" class="form-control" id="InputLastname" placeholder="Last Name"> </div>
                                            
                                            </td><td>
                                            <div class="mb-3">
                                <label for="address2">Address 2 *</label>
                                <input type="text" class="form-control" id="address2" placeholder=""> </div></td></tr>
                                </tbody></table>
                                </div></div></div>
                                
                            
     <div class="cart-box-main">
        <div class="container">
            <div class="row">
                <div class="col-lg-12">
                    <div class="table-main table-responsive">
                        <table class="table">
                            <thead>
                                <tr>
                                    <th>Images</th>
                                    <th>Product Name</th>
                                    <th>Price</th>
                                                                    </tr>
                            </thead>
                            <tbody class ="cart-items">
                                <tr class = "removebut">
                              
                                </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>

            

            <div class="row my-5">
                <div class="col-lg-8 col-sm-12"></div>
                <div class="col-lg-4 col-sm-12">
                    <div class="order-box">                                                                                                                                                                                                                                             
                        <div class="d-flex gr-total">
                            <h5>Grand Total</h5>
                            <div class="ml-auto h5"> <span id="total" class="d-flex-gr-total">$0.00</span></div>
                        </div>
                        <hr> </div>
                </div>
                <button onClick="sendMail" class= "sumbit type" type="submit">Sumbit</button>
            </div>

        </div>
    </div>

i think the problem is in the head so here is the html code of head so maybe some one with better experience then me can help me out im really sorry for too much questions but thats how i learn maybe some day i can help people aswell:)我认为问题出在头上,所以这里是 html 头代码,所以也许有人有更好的经验然后我可以帮助我,我真的很抱歉有太多问题,但这就是我学习的方式,也许有一天我也可以帮助人们: )

<html lang="en">
<!-- Basic -->

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">

    <!-- Mobile Metas -->
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <!-- Site Metas -->
    <title>Freshshop - Ecommerce Bootstrap 4 HTML Template</title>
    <meta name="keywords" content="">
    <meta name="description" content="">
    <meta name="author" content="">

    <!-- Site Icons -->
    <link rel="shortcut icon" href="images/favicon.ico" type="image/x-icon">
    <link rel="apple-touch-icon" href="images/apple-touch-icon.png">

    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="css/bootstrap.min.css">
    <!-- Site CSS -->
    <link rel="stylesheet" href="css/style.css">
    <!-- Responsive CSS -->
    <link rel="stylesheet" href="css/responsive.css">
    <!-- Custom CSS -->
    <link rel="stylesheet" href="css/custom.css">
    <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/emailjs-com@2/dist/email.min.js"></script>
<script type="text/javascript">
(function() {
emailjs.init("user_kYW9KXIGDrTbr7OrZS16g");
})();
</script>

You are not calling the sendMail() function.您没有调用 sendMail() function。 Also note that onclick attribute is not camelcase.另请注意,onclick 属性不是驼峰式。 Below line should work in your case.下面的行应该适用于您的情况。

<button onclick="sendMail()" class= "sumbit type" type="submit">Sumbit</button>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 未捕获的ReferenceError:HTMLFormElement.onsubmit中未定义emailjs - Uncaught ReferenceError: emailjs is not defined at HTMLFormElement.onsubmit ReferenceError:XMLHttpRequest 未在 emailjs 中定义 - ReferenceError: XMLHttpRequest is not defined in emailjs 我尝试使用 emailjs,但出现此错误“需要用户 ID”。 如何解决? - I try to use emailjs, but I have this error "user id is required". How to fix it? 当我尝试读取 Firebase 上的数据时,出现“未捕获的 ReferenceError:firebase 未定义”错误 - I am getting "Uncaught ReferenceError: firebase is not defined" error when i try to read my datas on Firebase 使用 emailjs 重新捕获后控制台出现“未捕获(在承诺中)TypeError”错误 - 'Uncaught (in Promise) TypeError' error in console after recaptcha with emailjs 当我尝试 type=&quot;module&quot; 时出现此错误(未捕获的 ReferenceError:loadFoods 未定义) - When I try type="module" get this Error ( Uncaught ReferenceError: loadFoods is not defined) 每当我想使用来自另一个文件的导出元素时出现“Uncaught ReferenceError: i is not defined”错误 - Getting "Uncaught ReferenceError: i is not defined" error whenever I want to use an exported element from another file 尝试将 Rollup 与 commonjs 结合使用时,为什么会出现“未捕获的 ReferenceError:exports is not defined”? - Why am I getting “Uncaught ReferenceError: exports is not defined” when trying to use Rollup with commonjs? 脱机时出现错误Uncaught ReferenceError:未定义$(...)(匿名&gt;函数) - When offline getting error Uncaught ReferenceError: $ is not defined(…)(anonymous > function) 我一直收到“未捕获的ReferenceError:未定义imgArray”错误 - I keep getting an “Uncaught ReferenceError: imgArray is not defined” error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM