Code Monkey home page Code Monkey logo

post-to-email's Introduction

Post to email

Image by fullvector on Freepik

Contact forms for static websites

Here's a solution for those with static websites wanting a contact form, but find themselves in a situation where they can't provide a script to support it (e.g. your platform doesn't allow you to host such script, or you simply don't know how)

This project provides a simple endpoint to submit your forms to, turning those form fields into an email to you.

All you need is:

  • An SMTP server, for outgoing mails (e.g. Gmail or Outlook)
  • A platform that supports deploying Docker containers (e.g. render)
  • Your static website with a form, hosted anywhere

For your convenience, this project is wrapped into a Docker container that can easily be deployed on any Paas - some of which will allow you to deploy this for free. Read on!

Instructions

1. Deploy the container

Run the matthiasmullie/post-to-email Docker container in whatever configuration makes sense.

Below are detailed instructions to run this in a couple of different ways - pick whichever makes most sense for your use-case:

2. Build a simple form & submit it

Submit a POST request (with remaining variables - see configuration)

Check out this simple example to build a form that submits forms to the service we deployed in the first step.

And here's information about mitigating spam in case you were worried about that!

3. Receive email

You've got this! We're done here.

Configuration

Email configuration can be set globally on the server hosting this script (via environment variables), or per request on the client calling this (via POST or GET params)

If set, environment variables always get precedence over POST, which gets precedence over GET params. This can be useful to lock down certain settings (e.g. RECIPIENT or DSN) within your hosting environment to prevent abuse.

Available params:

  • ALLOW_ORIGIN [ENV only]: allowed CORS domain
  • DSN [ENV only]: DSN string for a transport (e.g. SMTP) to send emails with
  • SENDER: sender email address
  • RECIPIENT: recipient email address
  • REPLY_TO (optional, defaults to SENDER): reply-to email address
  • SUBJECT (optional, defaults to "Form to email"): email subject
  • REDIRECT (optional, defaults to referrer): location to redirect back to after handing submission, or explicitly blank for no redirect
  • HONEYPOT (optional, defaults to none): Name of a form field to use as honeypot to filter out unwanted (spam) submissions

post-to-email's People

Contributors

matthiasmullie avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.