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>"
}'
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))
// ...
}
import grpc
from msgmorph.v1 import email_pb2, email_pb2_grpc
channel = grpc.secure_channel('api.simpleemailapi.dev:443', grpc.ssl_channel_credentials())
stub = email_pb2_grpc.EmailServiceStub(channel)
request = email_pb2.SendEmailRequest(
from_address="[email protected]",
to=["[email protected]"],
subject="Hello from Python!",
body="Sent via gRPC"
)
response = stub.SendEmail(request)
print(f"Sent: {response.id}")
Request Parameters
The sender email address. Must be from a verified domain.
Array of recipient email addresses.
HTML body content. If both body and html are provided, recipients will see HTML if their client supports it.
Custom key-value pairs for your reference.