Html 从托管在 GitHub 页面上的静态页面发送电子邮件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/24348223/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 02:06:36  来源:igfitidea点击:

Send email from static page hosted on GitHub Pages

htmlformshtml-emailgithub-pages

提问by A9S6

I have hosted a single static HTML page using GitHub Pages. I need to add a "Send Feedback" feature to my static page where a user can type in his name, email, comments and click the SUBMIT button. This will send an email with the contents to my email address. Can this somehow work in a static HTML page on GitHub? Does GitHub Pages support this mailing feature?

我使用 GitHub Pages 托管了一个静态 HTML 页面。我需要向我的静态页面添加“发送反馈”功能,用户可以在其中输入他的姓名、电子邮件、评论并单击“提交”按钮。这将向我的电子邮件地址发送一封包含内容的电子邮件。这可以在 GitHub 上的静态 HTML 页面中以某种方式工作吗?GitHub Pages 是否支持此邮寄功能?

I also want to know what features/plugins etc can GitHub Pages server support based on the underlying web server it uses?

我还想知道 GitHub Pages 服务器可以根据它使用的底层 Web 服务器支持哪些功能/插件等?

采纳答案by Moshe Katz

This cannot be done natively on GitHub pages. You will need to use somekindofform submission tool.

这不能在 GitHub 页面上本地完成。您将需要使用一些样的形式提交工具

GitHub's pages documentationdescribes what you can and cannot do with the hosting, and what plugins it supports.

GitHub 的页面文档描述了您可以使用托管做什么和不可以做什么,以及它支持哪些插件。

回答by Parvez Hassan

Yes it can be done this way with the help of formspee.

是的,它可以在 formpee 的帮助下以这种方式完成。

Formspree

大礼包

http://formspree.io/

http://formspree.io/

HTML forms Just send your form to our URL and we'll forward it to your email. No PHP, Javascript or sign up required — perfect for static sites!You just need to open your text editor, and paste the following code:

HTML 表单 只需将您的表单发送到我们的 URL,我们就会将其转发到您的电子邮件。无需 PHP、Javascript 或注册 — 非常适合静态网站!您只需要打开文本编辑器,然后粘贴以下代码:

<form action="http://formspree.io/[email protected]"><input type="email" name="_replyto"><textarea   name="body"></textarea><input type="submit" value="Send"></form>

That's it, your form already works! It will post the form onto an external domain, formspree.io, and send you an email with all the form content. No database. And you can just hit reply in your mailbox to continue the conversation with your visitor.

就是这样,您的表单已经可以使用了!它会将表单发布到外部域 formspree.io,并向您发送一封包含所有表单内容的电子邮件。没有数据库。您只需点击邮箱中的回复即可继续与访问者的对话。

This tool was built by the guys from Brace, then open-sourced and hosted by Assembly.

这个工具是由 Brace 的人构建的,然后由 Assembly 开源和托管。

Setting it up is easy and free. Here's how:

You don't even have to register.

  1. Setup the HTML form

Change your form's action-attribute to this and replace [email protected] with your own email.

http://formspree.io/[email protected]

  1. Submit the form and confirm your email address

Go to your website and submit the form once. This will send you an email asking to confirm your email address, so that no one can start sending you spam from random websites.

  1. All set, receive emails

From now on, when someone submits that form, we'll forward you the data as email.

设置它既简单又免费。就是这样:

您甚至不必注册。

  1. 设置 HTML 表单

将表单的 action-attribute 更改为此并将 [email protected] 替换为您自己的电子邮件。

http://formspree.io/[email protected]

  1. 提交表格并确认您的电子邮件地址

转到您的网站并提交一次表格。这将向您发送一封电子邮件,要求确认您的电子邮件地址,以便没有人可以开始从随机网站向您发送垃圾邮件。

  1. 一切就绪,接收邮件

从现在开始,当有人提交该表格时,我们会将数据作为电子邮件转发给您。

回答by user3835730

Github pages doesn't support php and some of the other backend stuff you'd need for this. A simple approach is to just create a google form which corresponds to your html form and use the action submit to that. It is a bit trickier to do it with out a redirect but it can be done.

Github 页面不支持 php 和您需要的一些其他后端内容。一个简单的方法是创建一个对应于您的 html 表单的谷歌表单,并使用提交操作。在没有重定向的情况下执行此操作有点棘手,但可以完成。

Here's how I did it: https://github.com/toperkin/staticFormEmails/blob/master/README.md

这是我的做法:https: //github.com/toperkin/staticFormEmails/blob/master/README.md

回答by juzraai

GitHub Pages doesn't offer/support anything like this, since it's just a static website hosting. It serves HTML files and assets, but doesn't run server side scripts.

GitHub Pages 不提供/支持这样的东西,因为它只是一个静态网站托管。它提供 HTML 文件和资产,但不运行服务器端脚本。

A few months ago I run into the same problem and did some research. As others mentioned, an external form handler service is needed for this task. Fortunately, there are tons of them:

几个月前,我遇到了同样的问题并做了一些研究。正如其他人提到的,此任务需要外部表单处理程序服务。幸运的是,有很多这样的:

I compared their features and limits based on their website, then I chose, tried out Basinand finally I stuck with it. It offers spam filter, captcha verification, Zapier integration; hides your email address in your form and it can send an email receipt to the one who submitted the form - all of this for free. It works like a charm on my website (hosted on GitHub Pages) behind my contact form.

我根据他们的网站比较了他们的功能和限制,然后我选择了,试用了Basin,最后我坚持了下来。它提供垃圾邮件过滤器、验证码验证、Zapier 集成;在表单中隐藏您的电子邮件地址,它可以向提交表单的人发送电子邮件收据 - 所有这些都是免费的。它在我的网站(托管在 GitHub Pages 上)上就像我的联系表后面的魅力一样。

EDIT:It offered unlimited submissions when I originally wrote this answer, but now a paid subscription is required for unlimited submissions and a redirect URL.

编辑:当我最初写这个答案时,它提供了无限提交,但现在无限提交和重定向 URL 需要付费订阅。

It's very easy to set up, the administration interface shows HTML snippets to copy-paste. Your form will look something like this:

设置非常简单,管理界面显示 HTML 片段以进行复制粘贴。您的表单将如下所示:

<form accept-charset="UTF-8" action="https://usebasin.com/f/123456xabcdef" enctype="multipart/form-data" method="POST">
  <input type="email" id="email" name="email" required>
  <textarea rows="4" cols="50" name="comment" required></textarea>
  <button type="submit">Submit</button>
</form>

Some time ago I wrote a blog postabout testing Basin with more details.

前段时间我写了一篇关于测试盆地的博客文章,其中包含更多细节。

回答by jandresrodriguez

Yes it can, there are many apps around the web that allows you to send emails from you static HTML with a couple of javascript lines. Some of them are mandrillapp, sendgrid, among others, and the best of them, they are all free !

是的,它可以,网络上有许多应用程序允许您使用几行 javascript 代码从静态 HTML 发送电子邮件。其中有些是mandrillapp,sendgrid,等等,和最好的人,他们都是免费的!

回答by Cole

Formspree founder here.

Formspree 创始人在这里。

Formspree has changed a bit in the last few years. It's now supports AJAX for free, spam filtering, optional captcha verification, and several built-in plugins including Zapier.

Formspree 在过去几年中发生了一些变化。它现在支持免费的 AJAX、垃圾邮件过滤、可选的验证码验证以及包括 Zapier 在内的几个内置插件。

The best way to get started is to create a form on the home page (https://formspree.io), or go to https://formspree.io/create. The old way of putting your email directly in the URL still works, but that exposes your email in the HTML, and requires an activation step. Creating a form in Formspree avoids the form activation step, and hides your email address.

最好的入门方法是在主页 ( https://formspree.io)上创建一个表单,或转到https://formspree.io/create。将您的电子邮件直接放在 URL 中的旧方法仍然有效,但这会将您的电子邮件暴露在 HTML 中,并且需要一个激活步骤。在 Formspree 中创建表单可避免表单激活步骤,并隐藏您的电子邮件地址。

There's lots of up-to-date information about Formspree's features and common issues at https://help.formspree.io/. The product continues to improve on a weekly basis. Come check it out!

https://help.formspree.io/ 上有很多关于 Formspree 的功能和常见问题的最新信息。该产品每周都会继续改进。快来看看吧!

回答by Prakhar Varshney

Why don't you create/Use Sendgrid(or anything like that) a smtp api , and use axios to post a request for sending any mail.

为什么不创建/使用 Sendgrid(或类似的东西)一个 smtp api,并使用 axios 发布发送任何邮件的请求。

回答by Jesper

I built https://www.formbackend.comfor things like these. The only thing you need is to create a form-backend on the website and use the unique URL as the actionin your <form action="[FORMBACKEND_UNIQUE_URL]">

我为这些东西构建了https://www.formbackend.com。您唯一需要做的是在网站上创建一个表单后端并使用唯一的 URL 作为action您的<form action="[FORMBACKEND_UNIQUE_URL]">

The field you add to the form will be submitted to our backend, where you can either view them online - or you can set it up so you receive an email every time someone submits your form! :)

您添加到表单中的字段将提交到我们的后端,您可以在其中在线查看它们 - 或者您可以设置它以便每次有人提交您的表单时您都会收到一封电子邮件!:)

回答by aks

No this is not supported by any static sites you will build. Yet there are a ton of services that can help you do this. Right now you just need a static formin your website but as time goes on you will want to do more things like:

不,您将构建的任何静态站点都不支持此功能。然而,有大量服务可以帮助您做到这一点。现在,您只需要static form在您的网站上添加一个,但随着时间的推移,您会想做更多的事情,例如:

  • What users are doing on your site
  • email them offers
  • increase engagement and a lot more.
  • 用户在您的网站上做什么
  • 电子邮件他们提供
  • 增加参与度等等。

I am trying out a tool Formester.comwhich will help you do all of this at an affordable price.

我正在尝试一个工具Formester.com,它将帮助您以可承受的价格完成所有这些工作。

回答by Sathananthan Sabesan

Unfortunately, You can't do via Github pages. You can achieve via a submission tool.

不幸的是,你不能通过 Github 页面来做。您可以通过提交工具实现。

I found an article from Medium.com. In the article, the author mentioned the http://formspree.io/as a submission tool. In this article author clearly mentioned the steps. I think this link is helpful for you.

我从Medium.com找到了一篇文章。在文章中,作者提到了http://formspree.io/作为提交工具。在这篇文章中作者清楚地提到了这些步骤。我认为这个链接对你有帮助。