Documentation Index
Fetch the complete documentation index at: https://docs.mailglyph.com/llms.txt
Use this file to discover all available pages before exploring further.
Use a secret key client for all email methods.
import (
"context"
"os"
mailglyph "github.com/MailGlyph/mailglyph-go"
)
client := mailglyph.New(os.Getenv("MAILGLYPH_SECRET_KEY"))
ctx := context.Background()
Send with basic HTML (Emails.Send)
subject := "Welcome"
body := "<h1>Hello</h1><p>Your SDK setup is working.</p>"
fromName := "MailGlyph Demo"
result, err := client.Emails.Send(ctx, &mailglyph.SendEmailParams{
To: "[email protected]",
From: &mailglyph.Recipient{Name: &fromName, Email: "[email protected]"},
Subject: &subject,
Body: &body,
})
if err != nil {
panic(err)
}
println(result.Success, result.Data.Timestamp)
Send to multiple recipients
To supports strings, recipient objects, or both:
_, err := client.Emails.Send(ctx, &mailglyph.SendEmailParams{
To: []interface{}{
"[email protected]",
&mailglyph.Recipient{Email: "[email protected]"},
},
From: "[email protected]",
Subject: strPtr("Product update"),
Body: strPtr("<p>New features are live.</p>"),
})
if err != nil {
panic(err)
}
Send with template and data
template := "tmpl_123"
_, err := client.Emails.Send(ctx, &mailglyph.SendEmailParams{
To: "[email protected]",
From: "[email protected]",
Template: &template,
Data: map[string]interface{}{
"firstName": "John",
"plan": "premium",
},
})
if err != nil {
panic(err)
}
Send with attachments
Attachment content should be Base64-encoded:
_, err := client.Emails.Send(ctx, &mailglyph.SendEmailParams{
To: "[email protected]",
From: "[email protected]",
Subject: strPtr("Your invoice"),
Body: strPtr("<p>Invoice attached.</p>"),
Attachments: []mailglyph.Attachment{
{
Filename: "invoice.pdf",
Content: "JVBERi0xLjQKJ...",
ContentType: "application/pdf",
},
},
})
if err != nil {
panic(err)
}
Send with advanced options
fromName := "Growth Team"
subscribed := true
_, err := client.Emails.Send(ctx, &mailglyph.SendEmailParams{
To: "[email protected]",
From: &mailglyph.Recipient{Name: &fromName, Email: "[email protected]"},
Subject: strPtr("Release notes"),
Body: strPtr("<p>Monthly update.</p>"),
Reply: strPtr("[email protected]"),
Name: strPtr("Monthly newsletter"),
Subscribed: &subscribed,
Headers: map[string]string{
"X-Campaign-Id": "monthly-2026-03",
},
})
if err != nil {
panic(err)
}
Verify an email address (Emails.Verify)
verification, err := client.Emails.Verify(ctx, "[email protected]")
if err != nil {
panic(err)
}
println(verification.Data.Valid)
println(verification.Data.IsRandomInput)
Handle typo suggestions
verification, err := client.Emails.Verify(ctx, "[email protected]")
if err != nil {
panic(err)
}
if verification.Data.IsTypo && verification.Data.SuggestedEmail != nil {
println("Did you mean:", *verification.Data.SuggestedEmail)
}
func strPtr(v string) *string { return &v }
See full endpoint details in the Send email API reference and Verify email API reference.