Skip to content
This repository has been archived by the owner on Aug 29, 2023. It is now read-only.

Super basic Ruby on Jets contact form receiver / mailer

License

Notifications You must be signed in to change notification settings

Niedziela-Solutions/serverless-contact-form

Repository files navigation

Serverless Contact Form (WIP)

Built with Ruby on Jets.

The goal with this is to provide a serverless endpoint to submit contact forms on static/serverless websites to. It just takes the email/body and sends to the configured email address.

Requirements

Setup

  1. bundle install
  2. cp .example.env .env.test
  3. cp .example.env .env.development

bundle exec jets server

Contact post endpoint is at: http://localhost:8888/contact

Example HTML page with form is provided here. You can use it locally to test the form submit.

Testing

bundle exec rspec

Linting

bundle exec rubocop -a

Infra Setup

  • SES with your domain and SMTP credentials made
  • Route 53 for DNS
  • AWS Certificate

Production ENV

Before deploying in production mode, you will need to setup your production env file. See the Custom Domain docs on the Ruby on Jets site for how the domain setup works and CORS Support

  1. cp .example.env.production .env.production
  2. Replace the env variables with what you need. Note: you can also reference SSM Parameter Store secrets.
DOMAIN=
HOSTED_ZONE_NAME=
CERT_ARN=

are needed for custom domain support.

Deploying

You will need to have an AWS IAM Profile setup. If it's not the default profile, you will need to prefix the deploy command with AWS_PROFILE=other.

JETS_ENV=production bundle exec jets deploy

Once deployed, it should create the subdomain and associate it with the API Gateway. From there, you can post /submit to it.