Skip to content

caporro/sub2gram

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sub2gram

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, ~8MB Docker image (scratch base)
  • Built for linux/arm64

How it works

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 }

Configuration

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)

Run with Docker

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:latest

Run with Docker Compose

services:
  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"

Build from source

# 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 .

Data

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.

Usage from a landing page

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"
  })
})

Telegram notification format

*myproject*
Email: `user@example.com`
Message: I want early access

License

MIT

About

Lightweight API to collect emails from landing pages and forward them to Telegram

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors