Skip to main content

Sending Emails

We provide a simple, reliable API for sending emails. You can use our specialized libraries, raw HTTP/JSON (Curl), or high-performance gRPC.

1. TypeScript SDK

The easiest way to get started is with our fully-typed TypeScript SDK.
npm install @msgmorph/sdk
import { createClient } from '@msgmorph/sdk';

const client = createClient({
  apiKey: 'em_test_...'
});

const result = await client.send({
  from: '[email protected]',
  to: ['[email protected]'],
  subject: 'Welcome!',
  // We recommend sending both HTML and plain text for best deliverability
  html: '<h1>Welcome to the platform!</h1>',
  body: 'Welcome to the platform!'
});

console.log(`Sent: ${result.id}`);

2. cURL (HTTP/JSON)

You can call the API directly using any HTTP client.
curl -X POST https://api.simpleemailapi.dev/v1/send \
  -H "Authorization: Bearer em_test_..." \
  -H "Content-Type: application/json" \
  -d '{
    "from": "[email protected]",
    "to": ["[email protected]"],
    "subject": "Hello via Curl",
    "body": "This is a plain text email sent via Curl.",
    "html": "<p>This is a <b>formatted</b> email.</p>"
  }'

3. High-Performance gRPC

For high-throughput applications, you can connect directly via gRPC/HTTP2. We publish our Protocol Buffers publicly. You can generate a client in any language (Go, Python, Java, Rust, etc.) using buf or protoc.
import (
    emailv1 "github.com/msgmorph/api/gen/v1"
    "github.com/msgmorph/api/gen/v1/emailv1connect"
)

func main() {
    client := emailv1connect.NewEmailServiceClient(
        http.DefaultClient,
        "https://api.simpleemailapi.dev",
    )

    req := &emailv1.SendEmailRequest{
        From:    "[email protected]",
        To:      []string{"[email protected]"},
        Subject: "Hello from Go!",
        Body:    "Sent via typed gRPC client",
    }
    
    resp, err := client.SendEmail(context.Background(), connect.NewRequest(req))
    // ...
}

Request Parameters

from
string
required
The sender email address. Must be from a verified domain.
to
string[]
required
Array of recipient email addresses.
subject
string
required
Email subject line.
body
string
Plain text body content.
html
string
HTML body content. If both body and html are provided, recipients will see HTML if their client supports it.
cc
string[]
Array of CC recipients.
bcc
string[]
Array of BCC recipients.
metadata
object
Custom key-value pairs for your reference.