Stamp0

Emails

View and manage received emails. Access email content, toggle between HTML and plain text, and extract verification links.

When emails are sent to your Stamp0 inbox address, they're stored and available for viewing in the console or via API.

Email Properties

Each email contains:

PropertyDescription
FromSender's email address
SubjectEmail subject line
BodyPlain text content
Body HTMLHTML formatted content
Received AtTimestamp when email arrived
Read StatusWhether you've viewed the email

Viewing Emails

In the Console

Navigate to an inbox to see its emails:

  1. Go to your project
  2. Click on an inbox row
  3. View the list of received emails

Email List

The email table shows:

ColumnDescription
StatusBlue dot = unread, no dot = read
FromSender's email address
SubjectEmail subject line
ReceivedWhen the email arrived

Email Detail View

Click on an email to view its full content:

  • Header: From, To, Subject, Date
  • Body: Rendered HTML or plain text
  • Toggle: Switch between HTML and plain text views

The email is automatically marked as read when you view it.

Programmatic Access

Getting Emails

import { Stamp0 } from '@stamp0/sdk';

const stamp0 = new Stamp0({ apiKey: process.env.STAMP0_API_KEY });

// Get all emails in an inbox
const emails = await stamp0.getEmails({
  inboxId: 'inb_xyz789',
});

console.log(emails[0].subject);
console.log(emails[0].body);
console.log(emails[0].bodyHtml);

Waiting for Email

// Wait for an email to arrive (polls until received or timeout)
const email = await stamp0.waitForEmail({
  inboxId: 'inb_xyz789',
  timeout: 30000, // 30 seconds
});

Getting Specific Email

const email = await stamp0.getEmail({
  inboxId: 'inb_xyz789',
  emailId: 'eml_abc123',
});

Extracting Content

Extract URLs from email body:

const email = await stamp0.waitForEmail({ inboxId: inbox.id });

// Extract verification link
const verifyLink = email.body.match(
  /https?:\/\/[^\s"<>]+(?:verify|confirm)[^\s"<>]*/i
)?.[0];

if (verifyLink) {
  await page.goto(verifyLink);
}
const resetLink = email.body.match(
  /https?:\/\/[^\s"<>]+(?:reset|password)[^\s"<>]*/i
)?.[0];

One-Time Passwords (OTPs)

Extract numeric codes from emails:

// 6-digit OTP
const otpMatch = email.body.match(/\b(\d{6})\b/);
const otp = otpMatch?.[1];

// 4-digit OTP
const otp4Match = email.body.match(/\b(\d{4})\b/);
const otp4 = otp4Match?.[1];

Custom Patterns

Use regex for any pattern:

// Extract order number like "ORD-12345"
const orderMatch = email.body.match(/ORD-(\d+)/);
const orderId = orderMatch?.[1];

// Extract tracking number
const trackingMatch = email.body.match(/tracking[:\s]+([A-Z0-9]+)/i);
const trackingNumber = trackingMatch?.[1];

Email Actions

Mark as Read

Emails are automatically marked as read when viewed in the console. You can also mark via API:

await stamp0.markAsRead({
  inboxId: 'inb_xyz789',
  emailId: 'eml_abc123',
});

Delete Email

await stamp0.deleteEmail({
  inboxId: 'inb_xyz789',
  emailId: 'eml_abc123',
});

Bulk Delete

In the console:

  1. Select multiple emails using checkboxes
  2. Click Delete Selected
  3. Confirm deletion

Multiple Emails

When an action triggers multiple emails (like signup sending welcome + verification):

// Wait for emails to arrive
await new Promise(resolve => setTimeout(resolve, 5000));

// Get all emails
const emails = await stamp0.getEmails({ inboxId: inbox.id });

// Find specific email by subject
const verificationEmail = emails.find(e =>
  e.subject.toLowerCase().includes('verify')
);

const welcomeEmail = emails.find(e =>
  e.subject.toLowerCase().includes('welcome')
);

Email Retention

Storage Policy:

  • Emails are stored for 30 days
  • After 30 days, emails are automatically deleted
  • Deleted emails cannot be recovered

Attachments

Coming Soon: Attachment support is planned for a future release. Currently, attachments are not stored.

Best Practices

1. Use Specific Patterns

Be specific when extracting content to avoid false matches:

// Good: Specific pattern
const link = email.body.match(/https:\/\/app\.example\.com\/verify\?token=[^\s"]+/)?.[0];

// Okay: General pattern (might match wrong links)
const link = email.body.match(/https?:\/\/[^\s]+verify[^\s]*/)?.[0];

2. Check HTML vs Plain Text

Some emails have content only in HTML:

// Try plain text first, fall back to HTML
let link = email.body.match(/verify[^\s]+/)?.[0];
if (!link) {
  link = email.bodyHtml.match(/href="([^"]+verify[^"]+)"/)?.[1];
}

3. Handle Missing Emails

Always handle the case where an email might not arrive:

try {
  const email = await stamp0.waitForEmail({
    inboxId: inbox.id,
    timeout: 30000,
  });
} catch (error) {
  console.error('Email not received within timeout');
  // Handle gracefully
}

Next Steps