Email API
Send emails through the SMSGist API or any of the official SDKs. Supports HTML content, file attachments, open/click tracking, and reply-to addresses.
Send a Basic Email
Using the SDKs
Go
client, err := zNotification.New("smsgist")
if err != nil {
log.Fatal(err)
}
resp, err := client.Send("email").
To("user@example.com", "other@example.com").
From("My App").
Subject("Welcome!").
Message("<h1>Hello</h1><p>Welcome to our platform.</p>").
Exec()
if err != nil {
log.Fatal(err)
}
fmt.Println(resp.MessageID) // "9c4d3e2f-..."
fmt.Println(resp.Status) // "queued"
fmt.Println(resp.RecipientsCount) // 2
fmt.Println(resp.TotalCost) // 0.002
PHP
use SMSGist\Client;
$client = Client::create();
$response = $client->send('email')
->to('user@example.com', 'other@example.com')
->from('My App')
->subject('Welcome!')
->message('<h1>Hello</h1><p>Welcome to our platform.</p>')
->exec();
echo $response->messageId; // "9c4d3e2f-..."
echo $response->status; // "queued"
echo $response->recipientsCount; // 2
echo $response->totalCost; // 0.002
Node.js
import { SMSGist } from '@smsgist/node';
const client = new SMSGist();
// Fluent builder
const response = await client.send('email')
.to('user@example.com', 'other@example.com')
.from('My App')
.subject('Welcome!')
.message('<h1>Hello</h1><p>Welcome to our platform.</p>')
.exec();
console.log(response.messageId); // "9c4d3e2f-..."
console.log(response.status); // "queued"
console.log(response.recipientsCount); // 2
// Or use the object-based API
const response2 = await client.email.send({
recipients: ['user@example.com'],
subject: 'Welcome!',
message: '<h1>Hello</h1><p>Welcome to our platform.</p>',
from: 'My App',
});
REST API
POST /api/email/send
{
"recipients": ["user@example.com", "other@example.com"],
"subject": "Welcome!",
"body": "<h1>Hello</h1><p>Welcome to our platform.</p>",
"from_name": "My App"
}
Response — HTTP 201
{
"status": "success",
"message": "Email queued for sending successfully",
"data": {
"message_id": "9c4d3e2f-8a7b-6c5d-4e3f-2a1b0c9d8e7f",
"status": "queued",
"recipients_count": 2,
"segments": 0,
"total_cost": 0.002,
"cost_per_unit": 0.001,
"recipients": [
{ "recipient_id": "a1b2c3d4-...", "recipient": "user@example.com" },
{ "recipient_id": "b2c3d4e5-...", "recipient": "other@example.com" }
]
}
}
Send with Attachments
All three SDKs support email attachments. You can attach files from disk or from in-memory data.
Go — From disk or memory
// Attach a file from disk
resp, err := client.Send("email").
To("user@example.com").
From("Billing").
Subject("Your Invoice — March 2026").
Message("<p>Please find your invoice attached.</p>").
AttachFile("/path/to/invoice.pdf").
Exec()
// Attach from memory (e.g. a generated CSV)
csvData := []byte("name,email\nJohn,john@example.com")
resp, err = client.Send("email").
To("user@example.com").
From("Reports").
Subject("Monthly Report").
Message("<p>Report attached.</p>").
Attach("report.csv", csvData).
Exec()
// Multiple attachments
resp, err = client.Send("email").
To("user@example.com").
From("Billing").
Subject("Invoice + Receipt").
Message("<p>Documents attached.</p>").
AttachFile("/path/to/invoice.pdf").
AttachFile("/path/to/receipt.pdf").
Exec()
PHP — From disk or memory
// Attach a file from disk
$response = $client->send('email')
->to('user@example.com')
->from('Billing')
->subject('Your Invoice — March 2026')
->message('<p>Please find your invoice attached.</p>')
->attachFile('/path/to/invoice.pdf')
->exec();
// Attach from string (e.g. a generated CSV)
$csvContent = "name,email\nJohn,john@example.com";
$response = $client->send('email')
->to('user@example.com')
->from('Reports')
->subject('Monthly Report')
->message('<p>Report attached.</p>')
->attach('report.csv', $csvContent)
->exec();
// Multiple attachments
$response = $client->send('email')
->to('user@example.com')
->from('Billing')
->subject('Invoice + Receipt')
->message('<p>Documents attached.</p>')
->attachFile('/path/to/invoice.pdf')
->attachFile('/path/to/receipt.pdf')
->exec();
Node.js — Base64-encoded data
The Node.js SDK accepts base64-encoded attachment data:
import { readFileSync } from 'fs';
// Read file and encode as base64
const pdfData = readFileSync('/path/to/invoice.pdf').toString('base64');
const response = await client.send('email')
.to('user@example.com')
.from('Billing')
.subject('Your Invoice — March 2026')
.message('<p>Please find your invoice attached.</p>')
.attach('invoice.pdf', pdfData)
.exec();
// Or using the object-based API
const response2 = await client.email.send({
recipients: ['user@example.com'],
subject: 'Your Invoice',
message: '<p>Invoice attached.</p>',
from: 'Billing',
attachments: [
{ filename: 'invoice.pdf', data: pdfData },
],
});
REST API
Attachments are sent as base64-encoded strings in the request body:
{
"recipients": ["user@example.com"],
"subject": "Your Invoice — March 2026",
"body": "<p>Please find your invoice attached.</p>",
"from_name": "Billing",
"attachments": [
{
"filename": "invoice.pdf",
"data": "JVBERi0xLjQKMSAwIG9iago8PA0..."
}
]
}
Reply-To Address
Set a reply-to address so recipients can reply to a different address than the sending address.
// Go
resp, err := client.Send("email").
To("user@example.com").
From("Support Team").
Subject("Ticket #4521 Update").
Message("<p>Your ticket has been updated.</p>").
ReplyTo("support@myapp.com").
Exec()
// PHP
$response = $client->send('email')
->to('user@example.com')
->from('Support Team')
->subject('Ticket #4521 Update')
->message('<p>Your ticket has been updated.</p>')
->replyTo('support@myapp.com')
->exec();
// Node.js
const response = await client.send('email')
.to('user@example.com')
.from('Support Team')
.subject('Ticket #4521 Update')
.message('<p>Your ticket has been updated.</p>')
.replyTo('support@myapp.com')
.exec();
Disable Tracking
By default, SMSGist tracks email opens and link clicks. You can disable this for privacy-sensitive emails like password resets or security alerts.
// Go
resp, err := client.Send("email").
To("user@example.com").
Subject("Reset Your Password").
Message("<p>Click <a href=\"https://myapp.com/reset/abc123\">here</a> to reset.</p>").
NoTracking().
Exec()
// PHP
$response = $client->send('email')
->to('user@example.com')
->subject('Reset Your Password')
->message('<p>Click <a href="https://myapp.com/reset/abc123">here</a> to reset.</p>')
->noTracking()
->exec();
// Node.js — fluent builder
const response = await client.send('email')
.to('user@example.com')
.subject('Reset Your Password')
.message('<p>Click <a href="https://myapp.com/reset/abc123">here</a> to reset.</p>')
.noTracking()
.exec();
// Node.js — object-based API
const response2 = await client.email.send({
recipients: ['user@example.com'],
subject: 'Reset Your Password',
message: '<p>Click <a href="https://myapp.com/reset/abc123">here</a> to reset.</p>',
noTracking: true,
});
Check Delivery Status
Same as SMS — use the message_id from the send response:
Using the SDKs
// Go
status, err := client.GetDeliveryStatus("9c4d3e2f-8a7b-...")
fmt.Println(status.Delivered)
fmt.Println(status.Failed)
// PHP
$status = $client->getDeliveryStatus('9c4d3e2f-8a7b-...');
echo $status->delivered;
echo $status->failed;
// Node.js
const status = await client.messages.getStatus('9c4d3e2f-8a7b-...');
console.log(status.delivered);
console.log(status.failed);
REST API
GET /api/message/{id}/status
The response includes email-specific tracking fields:
{
"data": {
"message_id": "9c4d3e2f-...",
"service": "email",
"status": "sent",
"total_recipients": 1,
"delivered": 1,
"pending": 0,
"failed": 0,
"recipients": [
{
"recipient_id": "a1b2c3d4-...",
"recipient": "user@example.com",
"send_status": "sent",
"delivery_status": "DELIVERED",
"delivered_at": "2026-03-21T10:30:15Z",
"opened_at": "2026-03-21T11:15:00Z",
"error_message": null
}
]
}
}
Email Delivery Status Values
| Status | Meaning |
|---|---|
DELIVERED | Email accepted by the recipient's mail server |
PENDING | Email sent, awaiting confirmation |
FAILED | Delivery failed |
BOUNCED | Recipient's mail server rejected the email |
For real-time delivery, open, click, and bounce events, use Webhooks.
Retry Failed Emails
Same as SMS — retry delivery to failed recipients only:
// Go
resp, err := client.Retry("9c4d3e2f-8a7b-...")
// PHP
$response = $client->retry('9c4d3e2f-8a7b-...');
// Node.js
const response = await client.messages.retry('9c4d3e2f-8a7b-...');
Request Fields Reference
POST /api/email/send
| Field | Type | Required | Description |
|---|---|---|---|
recipients | string | Yes | Email addresses |
subject | string | Yes | Subject line |
body | string | Yes | Email body (HTML supported) |
from_name | string | No | Sender display name |
reply_to | string | No | Reply-to email address |
no_tracking | boolean | No | Disable open/click tracking (default: false) |
attachments | array | No | File attachments (see below) |
attachments[].filename | string | Yes* | Filename with extension |
attachments[].data | string | Yes* | Base64-encoded file content |
route | string | No | "regular" (default) or "otp" |
*Required when attachments is provided.
Response Fields
| Field | Type | Description |
|---|---|---|
message_id | string | Unique ID — use this to check status or retry |
status | string | "queued" — the email is being processed |
recipients_count | int | Number of recipients |
total_cost | float | Total cost in GHS |
cost_per_unit | float | Cost per email (GHS 0.001) |
recipients | array | Per-recipient tracking IDs |
Pricing
| Country | Rate per email |
|---|---|
| Ghana | GHS 0.001 |
The total_cost in the response reflects the charge for all recipients.
