如何使用 HTML 表单发送电子邮件?

htmlweb developmentfront end technology更新于 2025/2/28 11:24:17

要使用 HTML 表单 发送电子邮件,您需要将电子邮件 ID 添加到表单的 action 属性中。在该属性中,添加电子邮件后跟 mailto:例如 mailto:emailid@example.com。

示例

您可以尝试运行以下代码,使用 HTML 表单发送电子邮件 -

<!DOCTYPE html>
<html>
   <body>
      <h2>Student Contact Form</h2>
      <form action="mailto:emailid@example.com" method="post" enctype="text/plain">
         Student Name:<br><input type="text" name="sname"> <br>
         Student Subject:<br><input type="text" name="ssubject"><br>
         <input type="submit" value="Send">
      </form>
   </body>
</html>


相关文章


有用资源