Crates.io | reformulate |
lib.rs | reformulate |
version | 0.4.0 |
source | src |
created_at | 2023-03-21 02:52:45.129553 |
updated_at | 2023-11-29 03:55:37.084033 |
description | reformulate is a standalone server that listens for web form data submissions. |
homepage | |
repository | https://code.orbitsolutions.dev/orb-it-solutions/formulate-actix |
max_upload_size | |
id | 815809 |
size | 109,437 |
A backend server application that listens for web form submissions, implemented with the actix-web framework. Minimum supported rust version (MSRV) is 1.62.1.
Configuration is currenly very simple and only two environment variables need to be set: FORMULATE_DESTINATION_EMAIL
and FORMULATE_SENDING_EMAIL
.
The "destination email" will be the email address you wish the form submissions to be sent to.
The "sending email" is the address the emails will come from when delivered to your inbox. It is meant to be a stable address which you can use to filter your form submission emails. This "sending email" will be used in the email's 'From:' header.
The 'Reply-To' address will be the email address submitted by the form's user.
Another pair of environment variables, FORMULATE_MAIL_RELAY_HOST
and FORMULATE_MAIL_RELAY_PORT
, are optional. These are used if relaying emails via the SMTP protocol is desired.
If set FORMULATE_MAIL_RELAY_HOST
defines the hostname for the relaying mail server.
FORMULATE_MAIL_RELAY_PORT
meanwhile always defaults to port 25, but allows users to define an alternate port which the mail relay is listening on.
It accepts the following parameters, most of which are required:
email
: The email address of the form sender. This will be set as the 'Reply-To' address in the sent email.from_site
: The URL of the site which the form is submitted from. Can also be submitted as site
, website
, or location
. Alternatively, for url-encoded form submissions, this can be set to the URL of the page the user should be redirected to if the form was submitted successfully. This form field can be hidden and set via JavaScript before submission.full_name
: The name the form sender would like to use in the sent email. This will be used as the email sender name. Can also be submitted as fullname
, or fullName
.message
: The message body of the sent emailsubject
: (optional) The title of the email. A default subject will be used if this is not provided.redirect
: (optional) Used to indicate if user wants to be redirected to from_site
URL. When submitted via JSON will need to be sent as a boolean value.After processing form submissions it responds with a message containing appropriate HTTP status codes, indicating success or failure.
Successful URL-encoded submissions will be redirected to the URL defined in the from_site
field when the redirect
value is true. If redirect
is omitted, or false, a message with an appropriate HTTP status is provided. On failure, a user readable error is sent bacl, with a relevant HTTP status.
JSON form submissions receive a JSON response with appropriate success or failure messages and HTTP statuses.
Rudimentary SPAM blocking functionality is now available in reformulate.
Optional blocklist functionality can be enabled by defining the FORMULATE_SPAM_BLOCKLIST
environment variable.
FORMULATE_SPAM_BLOCKLIST
should be a comma separated list of strings, formatted as domain names. These strings will be searched for in the form's message body and—if any match is found—result in form processing ending early. An error will be returned, with a message indicating the form submission is suspected SPAM. e.g. FORMULATE_SPAM_BLOCKLIST="acme.com, mega.lo.mania"
Another SPAM mitigation feature has been added. It is now possible to check form submission emails against the stopforumspam.org API. Enabling this feature will make reformulate slower because it has to make a network request to the API. It is also possible that network issues, or problems with the API itself result in failures. Any failure communicating with the API, or obtaining results from the API will result in the check being skipped. Only positive matches against the data will be considered valid SPAM.
This feature is enabled by setting the FORMULATE_SPAM_BLOCKING
environment variable to true.
A Dockerfile
is included in the source repository to aid in containerized deployments.