Git Product home page Git Product logo

lambda-email-forwarder's Introduction

Lambda/SES Email Forwarder

This project uses Amazon Lambda and API Gateway to forward emails using Amazon SES. It can be used on a static web site for example hosted on S3 as a contact form.

It is written in python and uses Chalice.

Deployment

To deploy it:

  1. Create a virtualenv with virtualenv venv then install the requirements with pip install -r requirements.txt.
  2. Export your AWS credentials in your shell
  3. Rename email-forwarder to something else
  4. Run chalice new-project email-forwarder
  5. Move the contents of whatever you renamed email-forwarder to into the email-forwarder directory generated by chalice.
  6. Change into the email-forwarder directory.
  7. Edit chalicelib/config.ini, updating it as necessary.
  8. Run chalice deploy from the directory containing app.py.

Note: If you're committing this to git, make sure to remove .chalice from email-forwarder/.gitignore to commit your chalice config files.

You can now POST JSON encoded messages with the following structure to the endpoint returned by chalice:

{
    "sender_name": <optional field for the sender's name>,
    "sender_email": <optional field for the sender's email address>,
    "body": <required field - the email body>,
    "domain": <required field - the domain of the site hosting the form. 
               This will be put in the subject field>,
}

Note: You need to set the content type to 'application/json'.

Usage

To use this, deploy as above, then generate a javascript SDK by running chalice generate-sdk examples/sdk and create a form like:

<form>
  <!-- Change this to match a whitelisted domain in `config.ini` -->
  <input type="hidden" name="domain" value="example.com" />
  <p><input type="text" name="sender_name" /></p>
  <p><input type="email" name="sender_email" /></p>
  <p><textarea name="body></textarea></p>
  <p><input type="submit"></p>
</form>

Finally, create some javascript to submit the form. You need to use javascript to submit the form because it needs to be submitted as JSON with a content type of application/json which isn't possible when directly submitting the form in a browser.

For a complete example, see the examples directory.

lambda-email-forwarder's People

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.