Send email from static page hosted on GitHub Pages

我只是一个虾纸丫 提交于 2019-11-27 02:54:06

This cannot be done natively on GitHub pages. You will need to use some kind of form submission tool.

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

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

Formspree

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:

<form action="http://formspree.io/you@email.com"><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.

This tool was built by the guys from Brace, then open-sourced and hosted by 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 your@email.com with your own email.

http://formspree.io/your@email.com

  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.

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.

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

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.

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 Basin and 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.

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.

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

<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 post about testing Basin with more details.

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 !

I built https://www.formbackend.com for things like these. The only thing you need is to create a form-backend on the website and use the unique URL as the action in your <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! :)

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 form in your website but as time goes on you will want to do more things like:

  • What users are doing on your site
  • email them offers
  • increase engagement and a lot more.

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!