You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Chris Smith 6fd2c0dab7 Mark fields as required 5 years ago
Dockerfile Initial version 5 years ago
LICENCE.adoc Initial version 5 years ago
README.adoc Credits and screenshots 5 years ago
example-email.png Credits and screenshots 5 years ago
example-form.png Credits and screenshots 5 years ago
failure.html Initial version 5 years ago
form.html Mark fields as required 5 years ago
go.mod Initial version 5 years ago
go.sum Initial version 5 years ago
main.go Send 303 not 307 5 years ago
success.html Initial version 5 years ago

README.adoc

= Go contact form

== About

Provides a simple, tiny webservice that serves a contact form and sends responses
via e-mail.

image:example-form.png[Example contact form] ->
image:example-email.png[Example email message]

== Usage

The simplest way to use this is via docker:

docker run -d csmith/contact-form -from form@server.com -to me@email.com .....

You should place this service behind an TLS-terminating proxy, and ensure it
is requested over a secure connection.

== Command line flags

----
-crsf-key string
CRSF key to use
-from string
address to send e-mail from
-port int
port to listen on for connections (default 8080)
-smtp-host string
SMTP server to connect to
-smtp-pass string
password to supply to the SMTP server
-smtp-port int
port to use when connecting to the SMTP server (default 25)
-smtp-user string
username to supply to the SMTP server
-subject string
e-mail subject (default "Contact form submission")
-to string
address to send e-mail to
----

_from_, _to_, _smtp-host_, _smtp-user_, and _smtp-pass_ are required; other options have vaguely sensible fallbacks.

== Templates

The form itself is loaded from `form.html` in the working directory; success and failure pages from `success.html`
and `failure.html` respectively. Each is loaded as a https://golang.org/pkg/html/template/[go html.template] and
can use the templating syntax described there.

The form must contain the `{{ .csrfField }}` template field, which will automatically insert the CSRF token for
the request.

== Credits

Developed by https://chameth.com[Chris Smith]; CSS heavily based on the login form in
https://github.com/greboid/ig[ig] by https://greboid.com[Greg Holmes].

== Licence

This software is licensed under the MIT licence. See the LICENCE.adoc file for the full text.