Lightweight HTTP API to collect emails from landing pages and forward them as Telegram notifications.
- Zero external dependencies — Go stdlib only
- One endpoint per project via URL path
- Persists submissions to per-project CSV files
- Logs errors to both console and file
- Single binary,
~8MBDocker image (scratchbase) - Built for
linux/arm64
POST /{project}
Content-Type: application/json
{ "email": "user@example.com", "message": "optional message" }
Each {project} maps to a separate CSV file in the data volume and appears in the Telegram notification. You can have as many projects as you want without rebuilding the image.
Response:
{ "ok": true }All configuration is passed via environment variables at container startup.
| Variable | Required | Description |
|---|---|---|
TELEGRAM_TOKEN |
yes | Telegram bot token |
TELEGRAM_CHAT_ID |
yes | Telegram chat/user ID to receive notifications |
CORS_ORIGINS |
no | Comma-separated list of allowed origins. If empty, all origins are allowed |
DATA_DIR |
no | Directory for CSV files and log (default: /data) |
PORT |
no | Listening port (default: 8080) |
docker run -d \
--name sub2gram \
-p 8080:8080 \
-v /opt/sub2gram/data:/data \
-e TELEGRAM_TOKEN=your_bot_token \
-e TELEGRAM_CHAT_ID=your_chat_id \
-e CORS_ORIGINS="https://yoursite.com,https://anothersite.com" \
caporro/sub2gram:latestservices:
sub2gram:
image: caporro/sub2gram:latest
restart: unless-stopped
ports:
- "8080:8080"
volumes:
- ./data:/data
environment:
TELEGRAM_TOKEN: your_bot_token
TELEGRAM_CHAT_ID: your_chat_id
CORS_ORIGINS: "https://yoursite.com,https://anothersite.com"# Clone
git clone https://github.com/caporro/sub2gram.git
cd sub2gram
# Build image for ARM64
docker buildx build --platform linux/arm64 -t sub2gram:latest .
# Build image for AMD64
docker buildx build --platform linux/amd64 -t sub2gram:latest .Submissions are saved in {DATA_DIR}/{project}.csv:
timestamp,email,message
2026-04-03T18:00:00Z,user@example.com,hello
Errors are logged to both stdout and {DATA_DIR}/app.log.
fetch("https://your-server.com:8080/myproject", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
email: "user@example.com",
message: "I want early access"
})
})*myproject*
Email: `user@example.com`
Message: I want early access
MIT