{"id":21316113,"url":"https://github.com/cjsaylor/contact-api","last_synced_at":"2026-05-17T12:31:22.769Z","repository":{"id":138151623,"uuid":"152819375","full_name":"cjsaylor/contact-api","owner":"cjsaylor","description":"Simple web service that takes a post request to a contact endpoint and sends an email to a configured target address with contact information.","archived":false,"fork":false,"pushed_at":"2018-10-19T18:50:36.000Z","size":100,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-22T10:36:31.800Z","etag":null,"topics":["api","contact","docker","golang","recaptcha-verification"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cjsaylor.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"license.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"security/nullvalidator.go","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-10-13T00:05:22.000Z","updated_at":"2018-10-19T18:44:34.000Z","dependencies_parsed_at":null,"dependency_job_id":"a52d58ad-cc38-44ab-b0fe-1e39fc7224ea","html_url":"https://github.com/cjsaylor/contact-api","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cjsaylor%2Fcontact-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cjsaylor%2Fcontact-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cjsaylor%2Fcontact-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cjsaylor%2Fcontact-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cjsaylor","download_url":"https://codeload.github.com/cjsaylor/contact-api/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243791867,"owners_count":20348532,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","contact","docker","golang","recaptcha-verification"],"created_at":"2024-11-21T18:29:47.215Z","updated_at":"2026-05-17T12:31:17.746Z","avatar_url":"https://github.com/cjsaylor.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Contact API\n\nSimple web service that takes a post request to a contact endpoint and sends an email to a configured target address with contact information. This service is particularly useful for sites deployed as static HTML.\n\n## Usage\n\nThe following endpoint is exposed:\n\n```\nPOST /contact?sender=\u0026subject=\u0026body=\n```\n\nHeaders:\n* `Content-Type`: `application/x-www-urlencoded-form`\n\n\n## Example implementation\n\nHere is an example html form (minimal) and JS script that utilizes the endpoint:\n\n```html\n\u003cform id=\"contactform\"\u003e\n\t\u003cinput type=\"email\" name=\"sender\" required\u003e\n\t\u003cinput type=\"text\" name=\"subject\" required\u003e\n\t\u003ctextarea name=\"body\" required\u003e\u003c/textarea\u003e\n\t\u003c!-- optional recaptcha spam filter --\u003e\n\t\u003cdiv class=\"g-recaptcha\" data-sitekey=\"YOUR-KEY-HERE\"\u003e\u003c/div\u003e\n\t\u003cbutton type=\"submit\"\u003eSubmit\u003c/button\u003e\n\u003c/form\u003e\n```\n\n---\n\n```js\nconst form = document.querySelector('#contactform');\nform.addEventListener('submit', function(e) {\n\te.preventDefault();\n\tconst formData = new FormData(form);\n\tfetch('https://yourdomain.com/contact', {\n\t\tmethod: 'POST',\n\t\tbody: new URLSearchParams(formData),\n\t})\n\t.then(res =\u003e {\n\t\tif (!res.ok) {\n\t\t\tthrow new Error(res.blob());\n\t\t}\n\t\tconsole.log('Message sent!');\n\t})\n\t.catch(err =\u003e {\n\t\tconsole.error('Message failed to send :(');\n\t});\n});\n```\n\n## Supported services\n\nEmail Services:\n\n* [Mailgun](https://www.mailgun.com)\n\nSpam Prevention Services:\n\n* [Recaptcha](https://www.google.com/recaptcha/)\n\n## Installation\n\n### Via Docker\n\n```bash\n$ docker pull cjsaylor/contact-api\n$ docker run --port 80:8080 --env \u003cconfig keys here\u003e cjsaylor/contact-api\n```\n\n### Via Golang build\n\n```bash\n$ go build -o web ./cmd/web/main.go\n$ ./web\n```\n\n## Configuration\n\nAll configuration is done by environment variables.\n\n| Env variable | Description\n| --- | ---\n| `PORT` | Port to expose the service (default: `8080`)\n| `CE_CORS_DOMAIN` | Domain to allow ajax requests through from the browser. See the [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS) for more details. (default `http://localhost:1313`)\n| `CE_TARGET_EMAIL` | Email address of whom will recieve the messages.\n| `RECAPTCHA_SECRET_KEY` | Recaptcha private API key, this is for spam protection. (optional)\n| `MG_DOMAIN` | Mailgun registerd domain\n| `MG_API_KEY` | Mailgun private api key\n| `CE_TEST_MODE` | By default test mode is engaged to prevent accidental email sending, you must specify `CE_TEST_MODE=false` in production. While engaged, it will only log the message posted.\n\n## Happy Users of this service\n\n* [Blue Trails Tech](https://www.bluetrailstech.com)\n\n## License\n\n[GNU GPL v3.0](license.md)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcjsaylor%2Fcontact-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcjsaylor%2Fcontact-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcjsaylor%2Fcontact-api/lists"}