Skip to main content
Glama
check-inbox-contents.js3.49 kB
#!/usr/bin/env node import { FastMailClient } from '../src/fastmail-client.js'; import dotenv from 'dotenv'; dotenv.config({ path: '../.env' }); async function checkInboxContents() { console.log('📥 CHECKING WHAT\'S ACTUALLY IN THE INBOX\n'); const client = new FastMailClient( process.env.FASTMAIL_API_TOKEN, 'clark@clarkeverson.com', 'clark@clarkeverson.com', 'clarkeverson.com', 'https://api.fastmail.com/jmap/session' ); try { await client.authenticate(); const mailboxes = await client.getMailboxes(); const inboxMailbox = mailboxes.find(mb => mb.name === 'Inbox'); if (!inboxMailbox) { console.log('❌ Inbox not found'); return; } console.log(`📧 INBOX CONTENTS (${inboxMailbox.totalEmails} emails):`); console.log('='.repeat(80)); let position = 0; let starredEmails = []; let unstarredEmails = []; while (position < inboxMailbox.totalEmails) { const emailResult = await client.getEmails(inboxMailbox.id, 25, position); if (!emailResult?.emails?.length) break; for (const email of emailResult.emails) { const sender = email.from?.[0]?.email?.toLowerCase() || ''; const subject = email.subject || ''; const preview = email.preview || ''; // Check if email is starred - only starred emails should stay const isStarred = email.keywords && email.keywords.includes('$flagged'); if (isStarred) { starredEmails.push({ from: sender, subject: subject, preview: preview.substring(0, 100), receivedAt: email.receivedAt }); } else { unstarredEmails.push({ from: sender, subject: subject, preview: preview.substring(0, 100), receivedAt: email.receivedAt }); } } position += emailResult.emails.length; } console.log('\n⭐ STARRED EMAILS (should stay in inbox):'); console.log('='.repeat(60)); if (starredEmails.length === 0) { console.log('✅ No starred emails found'); } else { starredEmails.forEach((email, index) => { console.log(`${index + 1}. FROM: ${email.from}`); console.log(` SUBJECT: ${email.subject}`); console.log(` PREVIEW: ${email.preview}...`); console.log(''); }); } console.log('\n📧 UNSTARRED EMAILS (should be organized):'); console.log('='.repeat(60)); if (unstarredEmails.length === 0) { console.log('✅ No unstarred emails found'); } else { unstarredEmails.forEach((email, index) => { console.log(`${index + 1}. FROM: ${email.from}`); console.log(` SUBJECT: ${email.subject}`); console.log(''); }); } console.log('\n📊 SUMMARY:'); console.log('='.repeat(40)); console.log(`⭐ Starred emails: ${starredEmails.length}`); console.log(`📧 Unstarred emails: ${unstarredEmails.length}`); console.log(`📧 Total: ${starredEmails.length + unstarredEmails.length}`); if (unstarredEmails.length === 0) { console.log('\n✅ PERFECT! Inbox contains only starred emails'); } else { console.log(`\n⚠️ ${unstarredEmails.length} unstarred emails need to be organized`); } } catch (error) { console.log('❌ Error:', error.message); } } checkInboxContents().catch(console.error);

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/gr3enarr0w/fastmail-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server