Gratilaus Form - Serverless Contact Form Backend for Static Sites with Amazon API Gateway, AWS Lambda, and Amazon SES

First Published:
Last Updated:

Gratilaus Form is a contact-form backend for static websites that you deploy to your own AWS account. One AWS SAM template creates an Amazon API Gateway endpoint and an AWS Lambda function that checks each submission and sends it to your inbox through Amazon SES; one deploy script checks your settings and deploys it. There is no database and no admin panel, and everything you can check before deploying runs locally without AWS credentials.

It is the companion to Gratilaus Site, whose contact page posts to it, but neither depends on the other: any page that can post the same JSON can use it. Unlike the other tools on this site, this is not a browser tool. You download it and deploy it from your own computer.

Download

Gratilaus Form 1.0.0 (released 2026-12-01, Gratilaus Attribution License 1.0)
gratilaus-form-1.0.0.zip (194 KB, 40 files)
SHA-256: d7db2313fca5c33f2089b503df3b1441ea38509033e5ece31c097d6ab73db1dd (.sha256 file)
Requires an AWS account, the AWS CLI, the AWS SAM CLI and Python 3.14 (or Docker).

Check the ZIP file before you unzip it. Run the command for your system in the folder where you saved it: it prints a SHA-256 hash that must match the one above (Windows prints it in upper case; the case does not matter). On macOS and Linux, if you also saved the .sha256 file next to the ZIP file, shasum -a 256 -c gratilaus-form-1.0.0.zip.sha256 (macOS) or sha256sum -c gratilaus-form-1.0.0.zip.sha256 (Linux) compares them for you.

  • macOS: shasum -a 256 gratilaus-form-1.0.0.zip
  • Linux: sha256sum gratilaus-form-1.0.0.zip
  • Windows (PowerShell): Get-FileHash .\gratilaus-form-1.0.0.zip -Algorithm SHA256
  • Windows (Command Prompt): certutil -hashfile gratilaus-form-1.0.0.zip SHA256

Platforms: each release is run and checked on macOS. Linux and Windows are supported on a best-effort basis: the scripts are plain Python, with a launcher for each OS, and are written and reviewed for both, but a release may not have been run on them. This release was also checked on Linux in Ubuntu 26.04 LTS, Ubuntu 24.04 LTS and Debian 13 containers (Docker) and on Windows 11 (Command Prompt and Windows PowerShell). If something breaks there, please report it (see "Support and Reports" below).

Release Notes

1.0.0 (2026-12-01) is the first release. It includes:

  • The built-in contact form, and form definition files (FORMS_FILE) that set the fields, checks, messages, subject and mail body of each form, with several forms on one stack.
  • The SES domain identity with Easy DKIM and its Route 53 records, created by the stack if you ask for them.
  • CORS answered by the function itself for the origins you list, preflight and post alike; API Gateway's own error responses carry CORS headers too, so a browser can read them.
  • Abuse limits: throttling, an optional cap on concurrent executions, a honeypot field, a length limit on every value and header-injection defenses.
  • Nearly every message the server returns in your site's language, including the 4XX and 5XX responses API Gateway generates itself (all but the one for a request over 10 MB).
  • A deploy script with launchers for macOS, Linux and Windows that checks origins, addresses, form definitions and the local Python before any AWS call, and compares a form page with its definition (--check-forms --html).
  • Local tests for the function, the form definitions, the page script and the deploy script that need no AWS account.
  • A step-by-step quick start and a one-sheet quick reference, in English and Japanese, which START_HERE.html in the ZIP file shows in your browser.

The complete list of changes is in CHANGELOG.md (English) and CHANGELOG.ja.md (Japanese) in the ZIP file.

Read the announcement: Introducing Gratilaus Site and Gratilaus Form - A Static Site Generator and a Contact Form Backend for AWS

Features

  • Serverless, in your own account: Amazon API Gateway (REST, Regional) with a Lambda proxy integration (Python 3.14, arm64) and Amazon SES. The mail goes to the address you set, from a sender address you have verified in SES.
  • SES setup included: optionally, the stack creates the SES domain identity with Easy DKIM and, when the domain's DNS is in an Amazon Route 53 hosted zone, writes its three DKIM CNAME records there, so no SES console step is needed to create the identity. DNS propagation and, for a new account, SES production access still take their own time.
  • CORS done in one place: the same function answers both the preflight and the post for the origins you list, so the browser can always read the reply to a message that was sent — otherwise a visitor sees an error and sends the form again. Access-Control-Allow-Origin: * is never sent.
  • Your own forms: without configuration it accepts the built-in contact form (name, email with confirmation, subject, message and consent). A JSON definition file sets the fields, checks, error messages, subject and mail body of each form, and one stack can take several forms.
  • Messages in your site's language: every message the server returns comes from the configuration or the definition file, including the body of API Gateway's own error responses. The texts that mailform.js shows on the page come from data-msg-* attributes in your page.
  • Abuse limits: a fixed recipient and sender, API Gateway throttling, an optional cap on concurrent executions, a honeypot field, a length limit on every value, and header-injection defenses. Visitors' messages are not written to the logs.
  • Checks before deploying: the deploy script stops, before any AWS call, on settings that would deploy fine and then fail every submission: a malformed origin or address, mixed-language messages, an invalid form definition, or a missing local Python 3.14 for sam build. --check-forms --html compares your form page with its definition without calling AWS.
  • Made to work with AI coding agents: AGENTS.md tells an agent which files are yours (the settings files, the form definitions and your site's pages) and which belong to the product, to add the credit line when it adds the form to a page, and that deploying and deleting the stack are yours to do.
  • Checks that need no AWS account: the tests, PRINT_PARAMETER_OVERRIDES=1 to print the settings the deploy would pass, and --check-forms (with --html to compare a page's form with its definition) all run without AWS and end with 0 only when everything passes, so a change can be checked before anything is deployed.
  • Launchers for each OS: deploy.sh for macOS and Linux and deploy.cmd for Windows run the same deploy.py, so the options and checks are the same everywhere.

How to Use

  1. Download the ZIP file above, check its SHA-256 hash, and unzip it. Open START_HERE.html in the unzipped folder (gratilaus-form-1.0.0) in your browser: it has the step-by-step quick start, including how to prepare Amazon SES, and the quick reference, in English and Japanese. The steps below are the short version. Then open a terminal in the unzipped folder.
  2. Install the AWS CLI and the AWS SAM CLI, and Python 3.14 (or set SAM_USE_CONTAINER=1 in the configuration file to build in a Docker container).
  3. Copy deploy.conf.example to conf/mysite.conf and set the AWS profile and Region, the stack name, the origins of your site, the notification address and the SES sender address. Optionally set FORMS_FILE to your form definition.
  4. Deploy:
    ./deploy.sh --conf conf/mysite.conf
    On Windows, run .\deploy.cmd --conf conf\mysite.conf.
  5. Put the printed MailFormEndpoint in your contact page. With Gratilaus Site, set it as mailform.endpoint in config/site.yaml and rebuild. For a page of your own, start from examples/contact.html (in Japanese: examples/contact.ja.html), which has the form, mailform.js and the credit line.
  6. Send one test message from your site and check that it arrives.

The included README.md (English) and README.ja.md (Japanese) document the contract with the page and the form definition format; deploy.conf.example explains every setting.

What's in the ZIP File

  • START_HERE.html — open it first: the quick start and the quick reference in your browser, in English and Japanese.
  • QUICKSTART.md, QUICK_REFERENCE.md (and .ja.md) — the same two guides as text.
  • README.md, README.ja.md — the full documentation (English and Japanese).
  • AGENTS.md — instructions for AI coding agents working in the folder: which files to change, the license's credit, and what to leave to you.
  • template.yaml — the AWS SAM template: the API, the function, its role and log group, and the optional SES identity and DNS records.
  • lambda/ — the function (handler.py), the form checks (forms.py) and an empty requirements.txt (the function needs nothing beyond the Lambda runtime).
  • deploy.py, deploy.sh, deploy.cmd, deploy.conf.example — the deploy script, its launchers and a commented sample configuration.
  • conf/ — where your own configuration and definition files go (Git ignores *.conf and *.json there); its README, in English and Japanese, explains when to use one stack or several.
  • frontend/mailform.js — the page script that posts a form to the endpoint (the same file ships with Gratilaus Site).
  • examples/ — a complete contact page in English and in Japanese (contact.html, contact.ja.html: the form, mailform.js and the credit line), a complete form definition (a Japanese-language event registration form with an inquiry form), and the built-in form without the visitor's IP address and browser.
  • tests/ — the local tests.
  • CHANGELOG.md, CHANGELOG.ja.md, LICENSE, NOTICE, SECURITY.md, CONTRIBUTING.md, CODE_OF_CONDUCT.md, requirements.txt (for editors and the local tests only), editor and Git settings (.editorconfig, .gitattributes, .gitignore), and a GitHub Actions workflow (.github/) that runs the tests if you keep your copy on GitHub.

Updating to a New Version

The code that runs in your AWS account changes only when you deploy, so a fix reaches your stack when you deploy the new version.

  1. Unzip the new version into a new folder and copy your configuration files from conf/ and your form definition files into it (or keep them elsewhere and point --conf and FORMS_FILE at them).
  2. Read the release notes, then run ./deploy.sh --conf conf/mysite.conf --check-forms, which checks your definition without calling AWS.
  3. Deploy with the new version's deploy.sh (or deploy.cmd), with the same STACK_NAME and AWS_REGION as before. The existing stack is then updated in place and the endpoint stays the same, unless the release notes say otherwise. (If an earlier deployment failed and left the stack in ROLLBACK_COMPLETE, the script deletes and recreates it, and the endpoint changes.)
  4. If the release notes say frontend/mailform.js changed, copy it to your site as well (with Gratilaus Site, it replaces assets/js/mailform.js).

Uninstalling

Remove the form from your site first, so that visitors do not post to an endpoint that is going away. Then delete the stack:

aws cloudformation delete-stack --stack-name <STACK_NAME> --profile <AWS_PROFILE> --region <AWS_REGION>
aws cloudformation wait stack-delete-complete --stack-name <STACK_NAME> --profile <AWS_PROFILE> --region <AWS_REGION>

A few things stay in your account afterwards, on purpose or because the stack does not own them:

  • The SES domain identity and its DKIM records, if the stack created them. They are kept so that anything else sending mail from the same domain keeps working; delete them in SES and Route 53 if nothing uses them. If you deploy again later, leave SES_DOMAIN_IDENTITY empty while the identity still exists: SES refuses to create it a second time.
  • API Gateway's execution log group, which API Gateway creates itself.
  • The S3 bucket sam-artifacts-<account>-<region> that the deploy script creates for the build artifacts (the packaged function, including your form definition) and reuses for every deployment in that account and Region. Check that nothing else uses it before you delete it.

If this stack created the account-level API Gateway logging role, deleting the stack also deletes that IAM role. The account setting then points to a role that no longer exists, and execution logging stops for the other APIs in that Region until you set another role.

Visitors' Personal Data

A contact form collects personal data, and running one makes you responsible for it.

  • What is sent: the fields of your form — with the built-in form, the visitor's name, email address, subject and message, and the consent box. Unless a form definition sets its own mail body, the notification mail also includes the visitor's IP address and browser (user agent) and the site the form was sent from.
  • Where it goes: from the visitor's browser to API Gateway and the Lambda function in the AWS Region you deploy to, then through Amazon SES (in that Region or the one you set) to your notification address.
  • What is kept: the project stores nothing: there is no database, and request bodies are not written to API Gateway's logs. The function's log lines never contain what a visitor typed: they name the form, the origin that posted and the kind of error, with email addresses in error messages masked. The function's log group keeps them for 90 days; API Gateway's own execution log group is created by API Gateway, and you can set its retention yourself. The message itself is kept only in your mailbox, for as long as you keep it.
  • Your part: tell visitors in your privacy policy what you collect, why, who receives it and how long you keep it. The built-in form requires a consent box, and examples/forms.contact-without-ip.json leaves the IP address and browser out of the mail if you do not want to collect them.

Third-Party Components and Licenses

Every file in the ZIP file is original work under the Gratilaus Attribution License 1.0; no third-party code is included. The function imports boto3 and botocore (Apache License 2.0), which the AWS Lambda Python runtime provides, and the template refers to the AWS managed policy AmazonAPIGatewayPushToCloudWatchLogs by name. To deploy, you install the AWS CLI and the AWS SAM CLI yourself. NOTICE lists the details.

About This Project

A static site has no server to receive a contact form, and the usual answers are a third-party form service or a hand-built backend. This project is a small, self-contained backend for that one job, kept narrow on purpose: it validates a submission and sends one mail to one fixed address. It does not store submissions, accept file attachments or send replies to the visitor.

Important Notes

  • License: the project is licensed under the Gratilaus Attribution License 1.0, which is derived from the Apache License 2.0 and differs from it mainly by an added Section 4A: a website whose form it processes, or that includes mailform.js, shows a credit, with rules for handing a site over to someone else and for a site that does not comply. Use, modification, redistribution and commercial use are otherwise allowed as under the Apache License 2.0. It is provided "as is", without warranties or conditions of any kind. The full terms are in the LICENSE and NOTICE files in the ZIP file, and the license text is also on this site.
  • Credit: a published site that uses this backend shows a short credit that contains "Gratilaus" and "H.K.", with a link whose text includes "H.K." or "Gratilaus" to hidekazu-konishi.com, for example Gratilaus Form by H.K. with H.K. linked. It goes on the pages that contain the form and the pages that load mailform.js, directly or through another script, including a bundled or renamed copy, typically as one line under the form: examples/contact.html in the ZIP file shows it. That applies while the form is the only part of a work under the license on your site; a site that also includes other files of such a work, such as a site built with Gratilaus Site, shows a credit on every page. Nothing adds it for you, except that a site built with Gratilaus Site already shows "Built with Gratilaus by H.K." in its footer, and that one credit is enough. The same goes for any site whose pages with the form already show such a credit, for example in their own footer: the credit does not have to be under the form. The credit must be visible on every screen size and color scheme the page supports without a click or hover, not hidden by your CSS or scripts, no smaller than the smallest other text in the same area, and with a contrast of at least 4.5:1 against its background (WCAG 2.2, 1.4.3), and its link has to reach hidekazu-konishi.com when followed; you may reword or translate it (keeping "Gratilaus" and "H.K." as they are) and add your own words, but not so that it disparages the software or its author or states or implies that the author endorses, sponsors or is responsible for your site. The rel attribute is your choice; rel="nofollow" is recommended. Instead of the credit, you may show a link to https://hidekazu-konishi.com/ whose text is exactly "hidekazu-konishi.com" — or an image link that shows the image given in the license, unaltered and at least 32 by 32 CSS pixels, with alternative text that includes "hidekazu-konishi.com" (you may host your own copy of the image) — visibly, on a page that visitors reach from your home page by following links without signing in, with the size and contrast rules of the credit and a link that works. Any link from the Link Kit on hidekazu-konishi.com/entry/links.html meets this. If you run the backend for forms on sites you do not publish yourself, tell the people who publish them about Section 4A. A site needs no credit yet while only the people who build, maintain, test, review or approve it, or only your own employees and contractors, can use it, and it requires signing in, is reachable only through a private network or a VPN, or is marked to be excluded from search engines (noindex or robots.txt); a site offered to the public is published, whatever it is called. If you give a site, or files for it, to someone else, give them the license and tell them about Section 4A: from then on it is theirs to keep (if you do not do both, it stays yours). A site that does not comply is not covered for that site until it complies (the license is not revoked); see NOTICE for the 30- and 60-day rules. The author may also ask you to remove the credit and the exemption link from a particular site; that site then needs neither, and from 30 days after the request the names may be used on it only as Section 6 of the license allows. You may use "Gratilaus", the product names and "H.K." in the credit, in the exemption link and to say truthfully that your site is built with this software, but not as part of the name of your own product or site, or in a way that suggests the author endorses it.
  • Websites built with it: the disclaimer for websites built with it, and what the credit means, are stated under Downloadable Software Disclaimer in the privacy policy.
  • Your AWS account: the stack creates resources in your own AWS account: an API Gateway API, a Lambda function, an IAM role, a CloudWatch log group and, if you ask for them, an SES identity and Route 53 records. AWS bills their use to your account. Deleting the stack removes them, except the SES identity and its DKIM records, which are kept so that other senders on the same domain keep working. API Gateway's own execution log group is created by API Gateway and is not removed with the stack.
  • The account-level API Gateway logging setting: if your account has no API Gateway CloudWatch role in that Region yet, the stack creates the role and sets it. The setting is shared by every API in the Region, and deleting the stack deletes the role it points to, which stops their execution logging until another role is set. The README explains why a long-lived environment should keep that role in a small stack of its own.
  • Amazon SES: the sender address must be verified in SES. While your account is in the SES sandbox, the notification address must be verified too.
  • The origin list is not a security boundary: it stops other websites from making their visitors' browsers post to your form, but not a script that calls the endpoint directly. Throttling and the fixed recipient are what limit abuse. SECURITY.md in the ZIP file explains the controls.
  • Platforms: macOS for every release; Linux and Windows on a best-effort basis. This release: also checked on Linux in Ubuntu 26.04 LTS, Ubuntu 24.04 LTS and Debian 13 containers and on Windows 11 (Command Prompt and Windows PowerShell).

Support and Reports

The latest stable release is the supported version. To report a bug or a suggestion, use any of the contact options on hidekazu-konishi.com. Report a security issue privately by email, as described in SECURITY.md in the ZIP file: the address is behind the Email link in the author's profile on the home page.

Getting New Versions

When a new version is released, this page is updated with its release notes, download link and SHA-256 hash, and its entry in this site's Atom and RSS feeds is refreshed. For scripts, releases.json lists each version published here with its release time, download URL and SHA-256 hash. Remember that a new version reaches your stack only when you deploy it.

FAQ

Does it work without Gratilaus Site?
Yes. Any page that posts JSON in the documented form works, including a hand-written HTML form with a small script. frontend/mailform.js in the ZIP file is a ready-made client. Either way the pages with the form show a credit, unless the site uses the exemption (see Important Notes); examples/contact.html is a complete page to start from.

Is it open source?
The source code is included, and you may use, modify and redistribute it, including for commercial work. The license has not been submitted to or approved by the Open Source Initiative, so it is not an OSI-approved open source license.

Does it store the messages it receives?
No. There is no database: each submission is checked and sent as one email, and the visitor's message is not written to the logs. If SES refuses a message, the visitor sees an error and can send again.

Can one deployment serve several sites?
Yes, if they share the same inbox, subject prefix and language: list each site's origin, and the mail says which site a message came from. A site that needs a different inbox or language gets its own stack.

Can I add my own fields, such as an event registration form?
Yes. A JSON definition file sets the fields, checks, messages and mail body of each form, and --check-forms checks it before you deploy. examples/forms.example.json in the ZIP file is a complete example.

Can I leave the visitor's IP address out of the mail?
Yes. The built-in form's mail ends with the visitor's IP address and browser. Set FORMS_FILE to examples/forms.contact-without-ip.json, the same form without those two lines, if your privacy policy does not cover them. Its messages are the English defaults; add a messages block for another language.

Can an AI coding agent set it up for me?
Up to the deploy, yes. AGENTS.md in the ZIP (an open format that tools such as Codex, GitHub Copilot and Cursor read; QUICK_REFERENCE.md says how to have Claude Code and Gemini CLI read it) asks the agent to write your settings file and form definitions, to add the credit line when it adds the form to a page, to check its work with the tests and --check-forms, and to leave the deploy to you, because a deploy changes resources in your AWS account and the form then sends real mail.

Related Tools

Related Articles


References:
Tech Blog with curated related content
Web Tools Collection

Written by Hidekazu Konishi