This is a simple web app built with the Fiber web framework and the GORM ORM that collects user emails and client information (IP address and user agent) and stores it in a SQLite database.
-
Clone the repository:
git clone https://github.com/xeronith/email-collector.git
-
Navigate to the project directory:
cd email-collector
-
Build the Docker image:
docker build -t email-collector .
-
Run the Docker container and mount a volume for the database:
docker run \ -p 8080:8080 \ -e POSTMARK_TOKEN="your-token" \ -e POSTMARK_FROM="from@yourdomain.com" \ -e POSTMARK_TEMPLATE_ALIAS="template-alias" \ -v /path/to/local/db:/app/db \ email-collector
-
Visit
http://localhost:8080
in your web browser to see the app in action.
The app has a single endpoint that collects user emails and client information and returns a JSON response:
-
POST /subscribe
Collects the user's email address and any additional data provided in the request body, as well as the client IP address information and user agent. Stores this information in the SQLite database and returns a JSON response containing a message.
Request Body:
{ "email": "user@example.com", "data": "additional data to log" }
Response Body:
{ "message": "your message goes here" }
The app uses the following third-party dependencies:
- Fiber - Web framework for Go.
- GORM - ORM library for Go.
- SQLite3 - SQLite3 driver for Go.
- Postmark - Email Delivery Service
This project is licensed under the MIT License.