API Documentation

Welcome to the golangsmtp API documentation.

POST /api/send-email

Sends an email to the configured portfolio owner's email address.

Authentication

All requests must include an API key in the headers. To request an API key, please email misbakhul2904@gmail.com.

HeaderDescription
X-API-KeyYour secret API key (required)

Request Format

The request body must be JSON and include the following fields:

FieldTypeDescription
sender_emailstringValid email address of the sender
subjectstringEmail subject (cannot be empty)
messagestringEmail body content (cannot be empty)

Example Request

curl -X POST https://smtp.misbakhul.my.id/api/send-email \
  -H "Content-Type: application/json" \
  -H "X-API-Key: your_api_key_here" \
  -d '{
    "sender_email": "test@example.com",
    "subject": "Hello",
    "message": "I want to work with you"
  }'

Responses

StatusDescriptionBody
200 OKEmail sent successfully{"message": "Email sent successfully"}
400 Bad RequestValidation failed{"error": "sender_email is not a valid email address"}
401 UnauthorizedMissing API key{"error": "missing X-API-Key header"}
403 ForbiddenInvalid API key{"error": "invalid API key"}
429 Too Many RequestsRate limit exceeded (5 req/min){"error": "too many requests, please slow down"}
500 Internal Server ErrorSMTP/Server error{"error": "failed to send email, please try again later"}

GET /health

Basic health check endpoint to verify the service is running.

Example Request

curl https://smtp.misbakhul.my.id/health

Example Response

{"status":"ok"}