html - 如何在电子邮件中发送 HTML 表单 .. 而不仅仅是 MAILTO

标签 html forms

我有一个供人们填写的 HTML 表单,我希望当他们点击提交按钮时,它只会发送电子邮件,而不是调出他们的电子邮件并要求他们自己发送消息。

当我使用时:

<form action="MAILTO:emailaddress@email.com"... >

所做的只是打开一个新窗口并填充电子邮件正文,但我希望它只发送一封电子邮件。

有没有办法格式化电子邮件的输出格式?而不仅仅是字段名称和输入值的列表。

谢谢。

最佳答案

> 2021 年答案 = 简单使用 GMail 的方法(5 分钟)

我们昨天有一个类似的挑战要解决,我们使用 Google Apps 脚本解决了它!

通过 Google 从没有后端(服务器)的 HTML 表单发送电子邮件!

实现该解决方案需要 5 分钟,并且我已使用分步说明 进行了记录: https://github.com/nelsonic/html-form-send-email-via-google-script-without-server

简要概述

A.使用示例脚本部署 Google App 脚本

将示例脚本部署为 Google 电子表格应用程序脚本: google-script-just-email.js

3-script-editor-showing-script

remember to set the TO_ADDRESS in the script to where ever you want the emails to be sent.
and copy the APP URL so you can use it in the next step when you publish the script.

B.创建您的 HTML 表单并将 action 设置为 App URL

使用示例 html 文件: index.html 创建一个基本表单。

7-html-form

remember to paste your APP URL into the form action in the HTML form.

C.在浏览器中测试 HTML 表单

在浏览器中打开 HTML 表单,输入一些数据并提交!

html form

提交表格。您应该看到已发送的确认信息: form sent

打开您设置的电子邮件地址的收件箱(上方)

email received

完成。

Everything about this is customisable, you can easily style/theme the form with your favourite CSS Library and Store the submitted data in a Google Spreadsheet for quick analysis.
The complete instructions are available on GitHub:
https://github.com/nelsonic/html-form-send-email-via-google-script-without-server

关于html - 如何在电子邮件中发送 HTML 表单 .. 而不仅仅是 MAILTO,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7449767/

相关文章:

html - :first selector not working in CSS

javascript - 如何限制用户在输入元素中输入 10 位数字?

Notepad++ 复制和粘贴到字符串上的特定位置

forms - 初始绑定(bind)时的 Angular2 ControlGroup valueChanges

java - 我如何知道点击了哪个提交按钮

html - 为li添加边框时出现错误

javascript - 具有固定位置的 Bootstrap 面板组 Accordion

html - 如何将这些 div 堆叠在一起?

javascript - PhantomJS 并单击表单按钮

javascript - 如何在没有页面源且没有 JSON 的情况下使 AJAX 读回响应?