Slingshot is a web application that forwards the body of a POST request to email. You provide SMTP email configuration details and Slingshot handles the rest. Deploy to Heroku's free tier to get going immediately, simply click the above button.
Slingshot exposes two endpoints: /ping
and /form
.
/ping
: [GET] Returns a 204 if all is well./form
: [POST] Sends the body to the configured recipients.
To check if the service is up:
curl -I --request GET 'localhost:8080/ping'
To send some form data:
curl -I --location --request POST 'localhost:8080/form' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'abc1=1234'
And lastly, see an example of an HTML form using Slingshot at example/index.html.
Slingshot can be configured via environment variables or by editing config.yaml
. Note that PORT
must always be provided via environment variable.
PORT
: This is the port that Slingshot runs on. If no PORT environment variable is provided, port 8080 is used.CORS
: This is a comma separated list of the valid domains you would like to allow access to Slingshot. This is not required but highly recommended.
SMTP_HOST
: The host of the SMTP email server to send with.SMTP_PORT
: The port of the SMTP email server to send with.SMTP_PASSWORD
: The password for your SMTP email account.EMAIL_FROM
: The email account to send from.EMAIL_TO
: The emails to send to. If more than one recipient, use a comma separated list.RECAPTCHA_SECRET
: Optional if reCAPTCHA token validation is needed.
PORT=8089 SMTP_HOST=smtp.example.com SMTP_PORT=587 SMTP_PASSWORD=PASSWORD [email protected] [email protected],[email protected] make run
smtpHost
: The host of the SMTP email server to send with.smtpPort
: The port of the SMTP email server to send with.smtpPassword
: The password for your SMTP email account.emailFrom
: The email account to send from.emailTo
: The emails to send to.recaptchaSecret
: Optional if reCAPTCHA token validation is needed.
smtpHost: smtp.example.com
smtpPort: 587
smtpPassword: PASSWORD
emailFrom: [email protected]
emailTo:
- [email protected]
- [email protected]
go get github.com/hashamali/slingshot
If you have Go set up locally, you can run Slingshot using:
PORT=8080 make run
Alternatively, you can use Docker. First, build the Slingshot image:
docker build --build-arg PORT=8080 -t slingshot .
Then, run it:
docker run -d -p 8080:8080 slingshot
Slingshot works quite well with Gmail. Setup is straight-forward:
- Create an App Password in Gmail.
- Configure
config.yaml
:
smtpHost: smtp.gmail.com
smtpPort: 587
smtpPassword: YOUR_APP_PASSWORD
emailFrom: [email protected]
emailTo:
- [email protected]
- [email protected]
Haven't gotten around to writing tests. Will add some soon if there is any interest.