FormMaillyGo API Documentation

๐Ÿ“ง Overview

FormMaillyGo is a powerful email service built with Go that runs on AWS Lambda. It allows you to send emails individually or in batches through simple REST API endpoints. Think of it as your personal email sending service that you can integrate into any website or application.

๐Ÿš€ Base URL

Base URL
https://your-lambda-function-url.amazonaws.com

๐Ÿ“ก API Endpoints

๐Ÿ  Home Page

Purpose: Display the main page of the FormMaillyGo service.

HTTP
GET /

When to use:

Response: HTML page with service information

Example:

curl
curl https://your-api-url.com/


๐Ÿ“ง Contact Form Email

Purpose: Receive contact form submissions directly to your email.

HTTP
POST /api/contact

When to use:

Request Body

JSON
{
  "name": "John Doe",
  "email": "john@example.com",
  "subject": "Hello from my website",
  "message": "This is a test message from the contact form.",
  "product_name": "My Awesome Website",
  "product_website": "https://mywebsite.com"
}

Contact Form Field Descriptions

Success Response (201)

JSON
{
  "message": "Email sent successfully"
}

Error Response (400)

JSON
{
  "error": "email is not a valid email address"
}

Example

curl
curl -X POST https://your-api-url.com/api/contact \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Alice Smith",
    "email": "alice@example.com",
    "subject": "Question about your service",
    "message": "Hi, I have a question about pricing.",
    "product_name": "My Store",
    "product_website": "https://mystore.com"
  }'


๐Ÿ“ฆ Send Batch Emails

Purpose: Send multiple emails efficiently in one request.

HTTP
POST /api/batch/contact

When to use:

Request Body (Array of emails)

JSON
[
  {
    "sent_to": "user1@example.com",
    "subject": "Welcome to our newsletter!",
    "message": "<h1>Thank you for subscribing to our newsletter.<\h1>",
    "product_name": "My Company"
  },
  {
    "sent_to": "user2@example.com",
    "subject": "Special offer just for you!",
    "message": "<h1>Get 50% off on all products this week.<\h1>",
    "product_name": "My Company"
  },
  {
    "sent_to": "user3@example.com",
    "subject": "Your order has been shipped",
    "message": "<h1>Your order #12345 is on its way!<\h1>",
    "product_name": "My Store"
  }
]

Field Descriptions

Response

Server-Sent Events (SSE) stream showing real-time progress:

SSE
data: {"email":"user1@example.com","status":"success"}


data: {"email":"user2@example.com","status":"success"}


data: {"email":"user3@example.com","status":"failed","error":"invalid email address"}

Response Fields

Example

curl
curl -X POST https://your-api-url.com/api/batch/contact \
  -H "Content-Type: application/json" \
  -d '[
    {
      "sent_to": "customer1@example.com",
      "subject": "Thank you for your purchase",
      "message": "Your order has been confirmed!",
      "product_name": "Online Store"
    },
    {
      "sent_to": "customer2@example.com",
      "subject": "Welcome to our service",
      "message": "We are excited to have you on board!",
      "product_name": "Online Store"
    }
  ]'

๐Ÿ“‹ Data Models

ContactForm Model

JSON
{
  "name": "string (required, max 100 chars)",
  "email": "string (required, valid email, max 255 chars)",
  "subject": "string (required, max 300 chars)",
  "message": "string (required)",
  "product_name": "string (optional)",
  "product_website": "string (optional, valid URL)"
}

Email Model

JSON
{
  "sent_to": "string (required, valid email)",
  "subject": "string (optional, max 300 chars)",
  "message": "string (required)",
  "product_name": "string (optional)"
}

EmailResult Model

JSON
{
  "email": "string (recipient email)",
  "status": "string (success/failed)",
  "error": "string (optional error message)"
}

Monitoring

๐Ÿ’š Health Check

HTTP
GET /api/health

When to use:

Response Structure

JSON
{
  "status": "healthy",
  "timestamp": "2025-08-25T12:39:00Z",
  "version": "1.0.0",
  "checks": [
    {
      "name": "memory",
      "status": "healthy",
      "latency": "1.2ms"
    },
    {
      "name": "goroutines",
      "status": "healthy",
      "latency": "0.8ms"
    },
    {
      "name": "error_rate",
      "status": "healthy",
      "latency": "0.5ms"
    }
  ],
  "metrics": {
    "uptime": "24h30m",
    "request_count": 150,
    "error_count": 2,
    "error_rate": 1.33
  }
}

๐Ÿ”ง Runtime Information

HTTP
GET /api/runtime-info

Response Structure

JSON
{
  "go_version": "go1.21.0",
  "num_cpu": 2,
  "num_goroutine": 5,
  "gomaxprocs": 2,
  "memory": {
    "alloc_bytes": 2048576,
    "total_alloc_bytes": 5242880,
    "sys_bytes": 8388608,
    "heap_alloc_bytes": 2048576,
    "heap_sys_bytes": 4194304,
    "num_gc": 3,
    "gc_cpu_fraction": 0.001
  },
  "environment": {
    "aws_lambda_function_name": "FormMaillyGo",
    "aws_lambda_function_version": "1",
    "aws_region": "us-east-1"
  }
}

๐Ÿ“Š Performance Metrics

HTTP
GET /api/metrics

Response Structure

JSON
{
  "uptime": "24h30m15s",
  "request_count": 1250,
  "error_count": 15,
  "error_rate": 1.2,
  "average_latency": "150ms",
  "min_latency": "50ms",
  "max_latency": "2s",
  "requests_per_second": 0.014,
  "emails_sent": 980,
  "emails_failed": 20,
  "email_success_rate": 98.0,
  "memory_usage_bytes": 2097152,
  "memory_peak_bytes": 4194304,
  "goroutines": 8,
  "goroutines_peak": 25,
  "cpus": 2,
  "go_version": "go1.21.0"
}

โš ๏ธ Error Handling

Common HTTP Status Codes

Validation Errors

JSON
{
  "error": "email is not a valid email address"
}

Common validation errors:

๐Ÿ›ก๏ธ Security Features

๐Ÿ“Š Performance & Scaling

Batch Processing Performance

Memory Management

๐Ÿ Getting Started

  1. Deploy FormMaillyGo to AWS Lambda
  2. Configure environment variables (Gmail credentials, SMTP settings)
  3. Test the service using the health endpoint
  4. Integrate the API endpoints into your application
  5. Monitor performance using the metrics endpoints

Happy emailing! ๐Ÿ“งโœจ