簡體   English   中英

通過 JavaScript/HTML 發送電子郵件確認?

[英]Send email confirmation through JavaScript/HTML?

我希望向在我的應用程序(只是一個測試應用程序)上注冊的用戶發送一封電子郵件,他們將收到一封確認電子郵件。

我不太確定如何解決這個問題,但我認為我需要在 register 函數中實現一些 javascript?

我已經發布了注冊過程中涉及的 JavaScript 和 HTML 代碼,因此非常感謝這里的任何幫助。

(使用 HTML、JavaScript、Phonegap、JQueryMobile)

謝謝。

HTML -

 <form onsubmit="registerUser(); return false;">
        <label for="txtusername">Username</label>
        <input type="text" id="txtusername">   <input type="submit" value="Check Availability" data-mini="true" onclick="return CheckUser()">
        <br>
        <label for="txtfirstname">First Name</label>
        <input type="text" id="txtfirstname">
        <label for="txtlastname">Surname</label>
        <input type="text" id="txtlastname" >
        <label for="txtemail">Email</label>
        <input type="email" id="txtemail" >
        <label for="txtpassword">Password</label>
        <input type="password" id="txtpassword" >
        <label for="passwordconfirm">Confirm Password</label>
        <input type="password" id="passwordconfirm" >
        <input type="submit" value="Register User">
        <input type="submit" value="Delete" onclick="return DeleteUser()">
    </form>

JavaScript -

 function registerUser() {
       var Username = document.getElementById("txtusername").value;
       var Firstname = document.getElementById("txtfirstname").value;
       var Lastname = document.getElementById("txtlastname").value;
       var Email = document.getElementById("txtemail").value;
       var Password = document.getElementById("txtpassword").value;
       var Confirmpass = document.getElementById("passwordconfirm").value;

         db = window.openDatabase("SoccerEarth", "2.0", "SoccerEarthDB", 2*1024*1024);
         db.transaction(function(tx) {
          NewUser(tx, Username, Firstname, Lastname, Email, Password, Confirmpass);
          }, errorRegistration, successRegistration);
          }

          function NewUser(tx, Username, Firstname, Lastname, Email, Password, Confirmpass) {
          var _Query = ("INSERT INTO SoccerEarth(UserName, FirstName, LastName, Email, Password, CPass) values ('"+ Username +"','"+ Firstname +"','"+ Lastname +"','"+ Email +"', '"+ Password +"', '"+ Confirmpass +"')");
           alert(_Query);
           tx.executeSql(_Query);
           }
           function errorRegistration(error) {
        navigator.notification.alert(error, null, "Got an error mate", "cool");
            }
           function successRegistration() {
           navigator.notification.alert("User data has been registered", null, "Information", "ok");
             $( ":mobile-pagecontainer" ).pagecontainer( "change", "#page4" );
         }

在瀏覽器中運行的 Javascript 無法發送電子郵件。 您將數據匯總到服務器,服務器可以構建和發送電子郵件。 數據庫也應該在服務器上。 由於這是一個測試應用程序,您可以使用在您的計算機上運行的 Apache、MySQL 和 PHP。 對於生產應用程序,您通常會租用服務器或使用后端作為服務。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM