Sign inSign up

jordanroher/email-page

By jordanroher

•Updated over 1 year ago

Turn JSON requests into HTML pages and send email links to them

Image
0

834

jordanroher/email-page repository overview

⁠Email Page

A Docker service that creates HTML pages from POST requests and sends email links to the generated pages.

⁠Features

  • Creates HTML pages from POST requests
  • Handles both plain text and HTML content
  • Sends email notifications with links to the created pages
  • Serves the HTML pages via unique URLs

⁠Environment Variables

VariableDescriptionDefault
PORTServer port3000
SMTP_HOSTSMTP server host(required for email)
SMTP_PORTSMTP server port25
SMTP_USERSMTP username(optional)
SMTP_PASSSMTP password(optional)
DOMAIN_NAMEDomain name for generated linkslocalhost:3000
EMAIL_FROMSender email address(required for email)
EMAIL_TORecipient email address(required for email)

⁠API Endpoints

⁠POST /new

Creates a new HTML page.

Request Body:

{
	"title": "Page Title",
	"message": "Page content goes here.\nThis will be converted to HTML."
}

If the message contains <html> tags, the entire message will be used as the HTML content.

Response:

  • 204 No Content on success
  • 400 Bad Request if title or message is missing
  • 500 Internal Server Error if page creation fails
⁠GET /:pageId

Serves an HTML page by its ID (timestamp).

For example, /2025-01-02-143376 will serve the file /etc/email-page/data/page-2025-01-02-143376.html.

Response:

  • HTML content of the page
  • 404 Not Found if page doesn't exist
  • 500 Internal Server Error if page serving fails

⁠Building and Running with Docker

  1. Build the Docker image:

    docker build -t emailpage .
    
  2. Run the container:

    docker run -p 3000:3000 \
      -e SMTP_HOST=smtp.example.com \
      -e SMTP_PORT=587 \
      -e [email protected] \
      -e SMTP_PASS=password \
      -e DOMAIN_NAME=example.com \
      -e [email protected] \
      -e [email protected] \
      -v /path/to/local/data:/etc/email-page/data \
      emailpage
    
  3. Or use with docker-compose: Create a docker-compose.yml file with the following content:

services:
    email-page:
        image: jordanroher/email-page
        container_name: email-page
        ports:
            - 3000:3000
        environment:
            - SMTP_HOST=smtp.example.com
            - SMTP_PORT=587
            - SMTP_USER=username
            - SMTP_PASS=password
            - DOMAIN_NAME=email-page.example.com
            - [email protected]
            - [email protected]
        volumes:
            - data:/etc/email-page/data

volumes:
    data:

Then run:

# Create a local data directory if it doesn't exist
mkdir -p data

# Start the service
docker-compose up -d

⁠Testing

You can test the API with curl:

curl -X POST http://localhost:3000/new \
  -H "Content-Type: application/json" \
  -d '{"title":"Test Page","message":"Hello, world!\nThis is a test page."}'

Tag summary

Content type

Image

Digest

sha256:eeb15f409…

Size

190.5 MB

Last updated

over 1 year ago

docker pull jordanroher/email-page