Skip to main content

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 MailGlyph from 'mailglyph';

const client = new MailGlyph(process.env.MAILGLYPH_SECRET_KEY as string);

Send with basic HTML

const result = await client.emails.send({
  to: 'user@example.com',
  from: {
    name: 'MailGlyph Demo',
    email: 'hello@your-verified-domain.com'
  },
  subject: 'Welcome',
  body: '<h1>Hello</h1><p>Your SDK setup is working.</p>'
});

console.log(result.success, result.data.timestamp);

Send to multiple recipients

to supports strings, recipient objects, or both:
await client.emails.send({
  to: [
    'one@example.com',
    { name: 'Two', email: 'two@example.com' }
  ],
  from: 'hello@your-verified-domain.com',
  subject: 'Product update',
  body: '<p>New features are live.</p>'
});

Send with template and data

await client.emails.send({
  to: 'user@example.com',
  from: 'hello@your-verified-domain.com',
  template: 'tmpl_123',
  data: {
    firstName: 'John',
    plan: 'premium'
  }
});

Send with attachments

Attachment content should be Base64-encoded:
await client.emails.send({
  to: 'user@example.com',
  from: 'billing@your-verified-domain.com',
  subject: 'Your invoice',
  body: '<p>Invoice attached.</p>',
  attachments: [
    {
      filename: 'invoice.pdf',
      content: 'JVBERi0xLjQKJ...',
      contentType: 'application/pdf'
    }
  ]
});

Send with advanced options

await client.emails.send({
  to: 'user@example.com',
  from: { name: 'Growth Team', email: 'hello@your-verified-domain.com' },
  subject: 'Release notes',
  body: '<p>Monthly update.</p>',
  reply: 'support@your-verified-domain.com',
  name: 'Monthly newsletter',
  subscribed: true,
  headers: {
    'X-Campaign-Id': 'monthly-2026-03'
  }
});

Verify an email address

const verification = await client.emails.verify('user@gmail.com');

console.log(verification.data.valid);
console.log(verification.data.isRandomInput);
console.log(verification.data.reasons);

Handle typo suggestions

const verification = await client.emails.verify('user@gmial.com');

if (verification.data.isTypo && verification.data.suggestedEmail) {
  console.log('Did you mean:', verification.data.suggestedEmail);
}
See full endpoint details in the Emails API reference.