https://github.com/perlogix/contactform-slack
Send contact form input to Slack with email validation and GeoLite2 information
https://github.com/perlogix/contactform-slack
Last synced: 3 months ago
JSON representation
Send contact form input to Slack with email validation and GeoLite2 information
- Host: GitHub
- URL: https://github.com/perlogix/contactform-slack
- Owner: perlogix
- License: apache-2.0
- Created: 2021-06-23T00:58:41.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2022-03-21T04:57:34.000Z (about 4 years ago)
- Last Synced: 2025-12-18T09:37:31.494Z (6 months ago)
- Language: Go
- Size: 39.1 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# contactform-slack
[](https://goreportcard.com/report/github.com/perlogix/contactform-slack)
Send contact form input to Slack with email validation and GeoLite2 information
# Features
- Small web service
- Validate email string
- Block bad user-agent requests
- JSON error messages
- Block free email addresses
- Parse GeoLite2 info for Slack message
- Detect browser user-agent and is mobile
- Send Slack message of contact information
# Example Slack Message Contents
`URL:` localhost:8080/contact
`Name:` Tim Ski
`Email:` tim@someemail.com
`Message:` Love the site!
`Browser:` Chrome
`Mobile:` false
`Country:` United States
`City:` McLean
`State:` Virginia
# Build
```sh
# Binary Build
make build
# Docker Build
make dbuild
## or
# Go build
CGO_ENABLED=0 go build -a -installsuffix cgo -o contactform-slack -ldflags -s -w .
# Create self-signed certs
openssl req -x509 -newkey rsa:4096 -nodes -keyout ./localhost.key -out ./localhost.pem -days 365 -sha256 -subj '/CN=localhost'
# Docker build
sudo docker build . -t perlogix:contactform-slack
```
# Docker Run
`./env-file` format
```sh
SLACK_URL=https://hooks.slack.com/services/...
REDIRECT_URL=https://somesite.com/contact
GEOLITE_DB=./GeoLite2-City.mmdb
```
```sh
make drun
# or
sudo docker run --name=contactform-slack -d -p 127.0.0.1:8080:8080 --env-file ./env-file --restart always perlogix:contactform-slack
```
# Example Request
```sh
curl -k -XPOST -H 'User-Agent: test-message' -F 'email=tim@someemail.com' -F 'name=tim ski' -F 'message=whats up' https://localhost:8080/contact
```
Responses
```json
{"error":"Email not valid"}
{"error":"Missing form information"}
```