我希望将电子邮件发送给在我的应用程序(只是一个测试应用程序)上注册的用户,他们将收到一封确认电子邮件。
我不太清楚如何解决这个问题,但我想我需要在寄存器功能中实现一些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" );
}
答案 0 :(得分:2)
在浏览器中运行的Javascript无法发送电子邮件。您将数据汇总到服务器,服务器可以构建和发送电子邮件。数据库也应该在服务器上。由于这是一个测试应用程序,您可以使用在您的计算机上运行的Apache,MySQL和PHP。对于生产应用程序,您通常会租用服务器或使用后端作为服务。