Integrated local email testing server that captures all outbound emails for development and testing
Yasumu includes a built-in catch-all SMTP server for testing email functionality in your applications. The server intercepts all emails sent to it, regardless of the recipient address, making it perfect for development and testing workflows.
const emails = await workspace.email.listEmails({ skip: 0, take: 50, sort: 'desc', // 'asc' or 'desc' by received time unread: true, // Filter by read/unread status search: 'query', // Search in subject, from, to, cc, and body});
// Get a specific email (marks as read by default)const email = await workspace.email.getEmail(emailId);// Get without marking as readconst email = await workspace.email.getEmail(emailId, false);
export function onEmail(email, env) { // Access email properties console.log('From:', email.from); console.log('Subject:', email.subject); // Parse email content const html = email.getHtml(); const text = email.getText(); // Extract verification codes, links, etc. const codeMatch = text.match(/code: (\d+)/); if (codeMatch) { // Save to environment for use in requests env.setVariable('verificationCode', codeMatch[1]); } // Process attachments for (const attachment of email.attachments) { console.log('Attachment:', attachment.filename); }}
Email scripts run automatically when new emails arrive, perfect for extracting verification codes, magic links, or triggering follow-up requests.