Skip to main content
Glama
aggressive-organization.js12 kB
#!/usr/bin/env node import { FastMailClient } from './src/fastmail-client.js'; import dotenv from 'dotenv'; dotenv.config({ path: '../.env' }); async function aggressiveOrganization() { console.log('🔥 AGGRESSIVE EMAIL ORGANIZATION - CATEGORIZING EVERYTHING\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(); // Get target mailboxes const targets = { 'Information/Newsletters': mailboxes.find(mb => { const parent = mailboxes.find(p => p.name === 'Information'); return parent && mb.parentId === parent.id && mb.name === 'Newsletters'; }), 'Financial/Receipts': mailboxes.find(mb => { const parent = mailboxes.find(p => p.name === 'Financial'); return parent && mb.parentId === parent.id && mb.name === 'Receipts'; }), 'Commerce/Orders': mailboxes.find(mb => { const parent = mailboxes.find(p => p.name === 'Commerce'); return parent && mb.parentId === parent.id && mb.name === 'Orders'; }), 'Professional/Security': mailboxes.find(mb => { const parent = mailboxes.find(p => p.name === 'Professional'); return parent && mb.parentId === parent.id && mb.name === 'Security'; }), 'Spam': mailboxes.find(mb => mb.name === 'Spam') }; const inboxMailbox = mailboxes.find(mb => mb.name === 'Inbox'); if (!inboxMailbox) return; console.log(`🔥 AGGRESSIVELY ORGANIZING ${inboxMailbox.totalEmails} INBOX EMAILS:`); console.log('='.repeat(80)); let categorized = 0; let spam = 0; let trulyActionable = 0; let position = 0; while (position < inboxMailbox.totalEmails) { const emailResult = await client.getEmails(inboxMailbox.id, 25, position); if (!emailResult?.emails?.length) break; console.log(`\n📧 Processing batch: emails ${position + 1}-${position + emailResult.emails.length}`); for (const email of emailResult.emails) { try { const sender = email.from?.[0]?.email?.toLowerCase() || ''; const subject = email.subject?.toLowerCase() || ''; const senderName = email.from?.[0]?.name?.toLowerCase() || ''; let targetPath = null; let reason = ''; // SPAM PATTERNS - Move to spam if ( // Health scams subject.includes('tea trick') || subject.includes('memory loss') || subject.includes('blood sugar') || subject.includes('vertigo') || subject.includes('prostate') || subject.includes('diabetes') || subject.includes('weight loss') || subject.includes('chocolate cake') || subject.includes('vision loss') || subject.includes('lung brew') || subject.includes('thyroid') || subject.includes('parkinson') || subject.includes('joints') || subject.includes('sciatica') || subject.includes('septic tank') || subject.includes('amino acid') || subject.includes('biblical') || subject.includes('mayo clinic') || // Financial/investment scams subject.includes('raise capital') || subject.includes('get cash from your home') || // Adult content subject.includes('milf') || subject.includes('wild night') || subject.includes('penile') || subject.includes('enhance love life') || // Suspicious domains/patterns sender.includes('@cube.dochltrowapp.com') || sender.includes('@petsitedeal.com') || sender.includes('@understandtermsofservice.com') || sender.includes('@techisam.com') || sender.includes('@roadreadynutrition.com') || sender.includes('@kitesslist.com') || sender.includes('@purecommercialcleaningco.com') || sender.includes('@carencorner.com') || sender.includes('@touchgrassstore.com') || sender.includes('@sleepapo2.com') || sender.includes('@blanco17.com') || sender.includes('@acompanhantestop.com') || sender.includes('@lprehome.com') || sender.includes('@track.raileuropetools.com') || sender.includes('@dalvasmart.com') || sender.includes('@pdfbit.com') || sender.includes('@thymetoeattexas.com') || sender.includes('@learningquail.com') || sender.includes('@lemanmotocover.com') || sender.includes('@unn.edu.ng') || sender.includes('@sleepcleanproducts.com') || sender.includes('@travelworldss.com') || sender.includes('@makeupfridges.com') || sender.includes('@ze-wellness.com') || sender.includes('@iqamanagebooks.com') || sender.includes('@learnaboutquail.com') || sender.includes('@lightingtreatments.com') || sender.includes('@ucm.ac.mz') || sender.includes('@yonemotoblog.com') || sender.includes('@httpseazypetsltd.com') ) { targetPath = 'Spam'; reason = 'Spam/scam content'; spam++; } // PROMOTIONAL/MARKETING - Move to newsletters else if ( // Promotional language subject.includes('sale') || subject.includes('off') || subject.includes('discount') || subject.includes('deal') || subject.includes('save') || subject.includes('savings') || subject.includes('flash sale') || subject.includes('final hours') || subject.includes('last chance') || subject.includes('ending now') || subject.includes('bonus deal') || subject.includes('mystery discount') || // Marketing senders sender.includes('@hello.grove.co') || sender.includes('@nationsphotolab.com') || sender.includes('@hello.misen.com') || sender.includes('@getsunday.com') || sender.includes('@mountainhighoutfitters.com') || sender.includes('@g2a.com') || sender.includes('@hello.gochirp.com') || sender.includes('@chipolo.net') || sender.includes('@relax.sleepsutera.com') || sender.includes('@contact@pepperpalace.com') || sender.includes('@m.shopifyemail.com') || // HSN/Shopping sender.includes('@emailhsn.com') || sender.includes('@h.emailhsn.com') || // Insurance quotes sender.includes('@geico.com') || sender.includes('@progressive.com') || subject.includes('quote') || subject.includes('insurance') || // General promotional patterns subject.includes('up to') || subject.includes('% off') || subject.includes('sitewide') || subject.includes('independence day') || subject.includes('4th of july') || subject.includes('holiday weekend') || subject.includes('summer sale') ) { targetPath = 'Information/Newsletters'; reason = 'Promotional/marketing content'; } // FINANCIAL - Legitimate financial services else if ( sender.includes('@cardpayexpress.com') || sender.includes('@marketing.lower.com') || sender.includes('@bluewatermtg.com') || sender.includes('@fairwaymc.com') || subject.includes('refinance') || subject.includes('mortgage') || subject.includes('fico score') || subject.includes('credit') || subject.includes('schwab funds') || subject.includes('@proxyvote.com') ) { targetPath = 'Financial/Receipts'; reason = 'Financial services'; } // COMMERCE - Online services and subscriptions else if ( sender.includes('@surveys.max.com') || subject.includes('azure') || subject.includes('delivery') || sender.includes('@etsy.com') || subject.includes('steam library') || subject.includes('expand') ) { targetPath = 'Commerce/Orders'; reason = 'Service/subscription'; } // EDUCATIONAL/INFORMATIONAL else if ( sender.includes('@uchicago.edu') || sender.includes('@edx.org') || sender.includes('@sfmc2.edx.org') || subject.includes('masters in applied') || subject.includes('start in august') || sender.includes('@greatbigphotographyworld.com') || sender.includes('@csmonitor.com') || subject.includes('usaid career') || subject.includes('photography world') ) { targetPath = 'Information/Newsletters'; reason = 'Educational/informational content'; } // LEGAL/SETTLEMENT NOTICES else if ( subject.includes('settlement') || subject.includes('legal notice') || subject.includes('class action') || subject.includes('fubo') || sender.includes('@emailksa.com') || sender.includes('@fubosettlement') ) { targetPath = 'Information/Newsletters'; reason = 'Legal notices'; } // PERSONAL COMMUNICATIONS - Keep in inbox only if truly personal else if ( // Actually personal emails (from real people, not businesses) (!sender.includes('@') || (sender.includes('@gmail.com') || sender.includes('@yahoo.com') || sender.includes('@hotmail.com') || sender.includes('@outlook.com')) && !subject.includes('sale') && !subject.includes('offer') && !subject.includes('deal') && !subject.includes('promo')) && // Not from businesses !sender.includes('noreply') && !sender.includes('no-reply') && !sender.includes('@hello.') && !sender.includes('@contact') && !sender.includes('@support') && !sender.includes('@team') && !sender.includes('@marketing') && !sender.includes('@info') ) { // This is potentially a real personal email - keep in inbox trulyActionable++; console.log(` 📥 [KEEP] ${email.subject?.substring(0, 50)}... (FROM: ${sender})`); continue; } // DEFAULT - Everything else goes to newsletters else { targetPath = 'Information/Newsletters'; reason = 'Default automated content'; } // Apply categorization if (targetPath && targets[targetPath]) { await client.moveEmailsToMailbox([email.id], targets[targetPath].id); categorized++; const icon = targetPath === 'Spam' ? '🗑️' : '✅'; console.log(` ${icon} [${categorized + spam}] ${email.subject?.substring(0, 40)}... → ${targetPath}`); } } catch (error) { console.log(` ❌ Error processing email: ${error.message}`); } } position += emailResult.emails.length; await new Promise(resolve => setTimeout(resolve, 1500)); } console.log('\n🎉 AGGRESSIVE ORGANIZATION COMPLETE!'); console.log('='.repeat(60)); console.log(`📧 Total emails categorized: ${categorized}`); console.log(`🗑️ Emails moved to spam: ${spam}`); console.log(`📥 Truly actionable emails in inbox: ${trulyActionable}`); console.log(`🎯 Inbox zero status: ${trulyActionable <= 5 ? '✅ ACHIEVED' : '⚠️ Close but needs review'}`); if (trulyActionable <= 5) { console.log('\n🎉 PERFECT INBOX ZERO ACHIEVED!'); console.log('✅ Only genuinely actionable emails remain in inbox'); } } catch (error) { console.log('❌ Error:', error.message); } } aggressiveOrganization().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