This is a very simple project to do the following:
-
Receive a POST from an HTML form - expected parameters are
from_name
from_email
title
body
And the
Content-Type
should beapplication/x-www-form-urlencoded
. -
Convert that POST into an email to a pre-defined email address, via Mailgun's API
-
Redirect to a predefined URL with the parameters
status
andmessage
(if status iserror
)
That's it - it's very simple
cargo build --release
brew install filosottile/musl-cross/musl-cross
CC_x86_64_unknown_linux_musl="x86_64-linux-musl-gcc" cargo build --release --target=x86_64-unknown-linux-musl
sudo apt-get install musl-tools
CC_x86_64_unknown_linux_musl="musl-gcc" cargo build --release --target=x86_64-unknown-linux-musl
MAILGUN_API_KEY="<insert api key>" \
MAILGUN_DOMAIN="<insert mailgun domain>" \
MAILGUN_TO_ADDRESS="<insert address to send posted data to>" \
MAILGUN_REDIRECT_URL="<HTTP address to redirect with 303 to after processing POST>" \
./target/release/mailgun-contact-form
RUST_LOG
: Control the logging level. Set toactix_web=info,mailgun_contact_form=info
to get basic logging for the web framework and the applicationBIND_ADDRESS
: The address to bind to. Defaults to0.0.0.0
PORT
: The port to bind to. Defaults to8088