首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >回复表格,对Gmail的回复

回复表格,对Gmail的回复
EN

Stack Overflow用户
提问于 2022-08-09 06:41:07
回答 1查看 66关注 0票数 -2

今天,我尝试使用html、css和js创建一个表单,它将在运行代码时将响应发送到codes...but中输入的邮件ID --在单击Submit按钮后,响应不会在邮件上运行。下面是我尝试过的代码:

代码语言:javascript
复制
<!doctype html>
<html>
<head>
<meta name="viewport" content="width-device-width, initial-scale=1.0">
<title>codeG</title>
<link rel="stylesheet" href="Style.css">
</head>
<body>
     <div class="container">

<form onsubmit="sendEmail(); reset(); return false;">

<h3> LOGIN FORM <hr width="50px" style="background: #555; height:5px"></h3>
<input type="text" id="name" placeholder="Full Name" required>
<input type="email" id="email" placeholder="Valid Email" required>
<input type="text" id="phone" placeholder="Valid Phone no." required>
<textarea id="message" rows="4" placeholder="Leave a comment..."></textarea>
<button type="Submit"> Submit </button>

</form>

    </div>
    <script src="https://smtpjs.com/v3/smtp.js">
</script>
   <script>
    function sendEmail(){
    Email.send({
    Host : "smtp.gmail.com",
    Username : "ayushbharti.official123@gmail.com",
    Password : "*********",
    To : 'ayushbharti.official123@gmail.com',
    From : document.getElementById("email").value,
    Subject : "New Contact Form Equiry",
    Body : "Name: " + document.getElementById("name").value
    + "<br> Email:" + document.getElementById("eamil").value
    + "<br> Phone no.:" + document.getElementById("phone").value
    + "<br> Message:" + document.getElementById("message").value
}).then(
  message => alert("Message Sent Successfully")
);
    }
   </script>
</body>
</html>

请试着解决我提到的路径

上的问题

EN

回答 1

Stack Overflow用户

发布于 2022-08-09 08:27:28

我认为您的form标签中有一个问题。

让我描述一下

代码语言:javascript
复制
function sendEmail() {
  Email.send({
    Host: "smtp.gmail.com",
    Username: "ayushbharti.official123@gmail.com",
    Password: "*********",
    To: 'ayushbharti.official123@gmail.com',
    From: document.getElementById("email").value,
    Subject: "New Contact Form Equiry",
    Body: "Name: " + document.getElementById("name").value +
      "<br> Email:" + document.getElementById("eamil").value +
      "<br> Phone no.:" + document.getElementById("phone").value +
      "<br> Message:" + document.getElementById("message").value
  }).then(
    message => alert("Message Sent Successfully")
  );
}
代码语言:javascript
复制
<div class="container">
  <!--first disable default action of the form -->
  <form onsubmit="return false;sendEmail(); reset();">

    <h3> LOGIN FORM
      <hr width="50px" style="background: #555; height:5px">
    </h3>
    <input type="text" id="name" placeholder="Full Name" required>
    <input type="email" id="email" placeholder="Valid Email" required>
    <input type="text" id="phone" placeholder="Valid Phone no." required>
    <textarea id="message" rows="4" placeholder="Leave a comment..."></textarea>
    <button type="Submit"> Submit </button>

  </form>

</div>
<script src="https://smtpjs.com/v3/smtp.js">
</script>

票数 -1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73287483

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档