Sign inSign up

drumsergio/nginx-mailer

By drumsergio

Updated 29 days ago

Image
0

3.3K

drumsergio/nginx-mailer repository overview

nginx-mailer banner

nginx-mailer

License Docker Pulls Docker Image Size

Lightweight Docker image based on nginx:alpine that serves static websites and handles contact form submissions via SMTP.


Features

  • 🚀 Based on nginx:1.29-alpine (~35MB total)
  • 📧 Built-in contact form API with SMTP support
  • 🔒 Cloudflare Turnstile CAPTCHA integration
  • 🐳 Single container (nginx + Go API)
  • 🏗️ Multi-arch: linux/amd64 and linux/arm64

Quick Start

docker run -d \
  -p 80:80 \
  -v /path/to/site:/usr/share/nginx/html:ro \
  -e SMTP_HOST=smtp.example.com \
  -e SMTP_PORT=465 \
  -e [email protected] \
  -e SMTP_PASSWORD=your-password \
  -e [email protected] \
  -e [email protected] \
  drumsergio/nginx-mailer:latest

Docker Compose

services:
  website:
    image: drumsergio/nginx-mailer:latest
    ports:
      - "80:80"
    volumes:
      - ./website:/usr/share/nginx/html:ro
    environment:
      - SMTP_HOST=smtp.example.com
      - SMTP_PORT=465
      - [email protected]
      - SMTP_PASSWORD=your-password
      - [email protected]
      - SMTP_FROM_NAME=My Website
      - [email protected]
      - CLOUDFLARE_TURNSTILE_SECRET_KEY=  # Optional
    restart: unless-stopped

Environment Variables

VariableRequiredDescription
SMTP_HOSTYesSMTP server hostname
SMTP_PORTYesSMTP port (465 for SSL, 587 for STARTTLS)
SMTP_USERYesSMTP username
SMTP_PASSWORDYesSMTP password
SMTP_FROMYesFrom email address
SMTP_FROM_NAMENoFrom display name
CONTACT_EMAILYesRecipient email for contact forms
CLOUDFLARE_TURNSTILE_SECRET_KEYNoTurnstile secret key

API

POST /api/contact
{
  "nombre": "John Doe",
  "email": "[email protected]",
  "telefono": "+1234567890",
  "ubicacion": "City",
  "mensaje": "Hello...",
  "cf-turnstile-response": "token"
}
GET /health

Returns 200 OK for health checks.

HTML Form Example

<form action="/api/contact" method="POST">
  <input type="text" name="nombre" placeholder="Name" required>
  <input type="email" name="email" placeholder="Email" required>
  <input type="tel" name="telefono" placeholder="Phone">
  <textarea name="mensaje" placeholder="Message" required></textarea>
  
  <!-- Optional: Cloudflare Turnstile -->
  <div class="cf-turnstile" data-sitekey="your-site-key"></div>
  <script src="https://challenges.cloudflare.com/turnstile/v0/api.js" async defer></script>
  
  <button type="submit">Send</button>
</form>

License

MIT

Tag summary

Content type

Image

Digest

sha256:85c8dc510

Size

44.5 MB

Last updated

7 months ago

docker pull drumsergio/nginx-mailer