rclement / mailer

Dead-simple mailer micro-service for static websites
https://rclement.github.io/mailer/
GNU Affero General Public License v3.0
58 stars 8 forks source link

Allow to send e-mails using form submission #198

Closed rclement closed 3 years ago

rclement commented 3 years ago

Currently, only a JSON API endpoint is available at /api/mail. When using SSG without JS AJAX support, sending form with a simple HTTP POST request using the application/x-www-form-urlencoded content-type would be a nice universal and fallback solution.

However, FastAPI does not allow multiple content-type body request for a single route:

The preferred way seems to go towards having separate routes based on content-type.

One more thing: when using a POST form submission, redirections will be required! One easy way to do it would be to setup:

This pattern is called "POST/Redirect/GET": https://en.wikipedia.org/wiki/Post/Redirect/Get

As a reference, Formspree is doing something similar with its "Thank You Redirect": https://help.formspree.io/hc/en-us/articles/360012378333--Thank-You-redirect

rclement commented 3 years ago

Some more specifications.

Configuration

Optional new configurations:

Question: these configurations are required when using the form submission API? Do we redirect to Origin when not specified?

API