我的问题是,我知道chrome浏览器无法执行常见的js模块,但在node js文件中,它将所有内容导入为common js,chrome显示错误,如果我使用ecmascript(e26)模块导入NodeEmailer,它会说无法导入一个模块而不是一条语句,所以这两个错误是如何解决的,或者我的技术错误插入nodeEmailer plz帮助我,然后提前发出一个提示,这是我的代码
import * as nodemailer from "nodemailer"
var a=Math.round(Math.random()*999999);
c=document.getElementById("p");
var b=c;
function otpch(){
if(document.getElementById("optcheck").value===a){
document.open();
document.write("You are successfully Logged In")
}
}
function otpm(){
alert(4236)
var mailOptions = {
from: 'mygmailid@gmail.com',
to: b,
subject: 'Your Otp',
text: 'Your onetime otp is'+a
};
alert(4236)
var transport = nodemailer.createTransport({
service: 'gmail.com',
auth: {
user:'friendsgmailid@gmail.com',
pass:'itssecret'
}
});
alert("hi123");
transport.sendMail(mailOptions,function(err,info){
if(err) {
document.getElementById("demo").innerHTML="Error while sending otp please check your gmail id which you filled is correct or not ";
} if(info){
document.getElementById("demo").innerHTML="Otp Sent Successfully";
}
});
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script type="module" src="nodemailer/lib/nodemailer.js"></script>
<script src="sketch.js"></script>
</head>
<body >
<h3>Welcome to our site jain services</h3>
<h5>Write Your Gmail Address</h5>
<p id="p"><input id="gmailcheck"type="email" placeholder="Write Your Gmail" required></p>
<h4>click on the button to sign in</h4>
<button onclick="otpm()" type="submit"id="un" style="border: 3px solid black; border-radius: 50px;">Submit</button>
<h3 id="demo" style="color: red;">.</h3>
<input id="otpcheck" onclick="otpch()" type="number">
</body>
</html>
暂无答案!
目前还没有任何答案,快来回答吧!