A step-by-step assistant for cleaning up, backing up, and optimizing your NetEase 126.com email account via IMAP. Designed to help reclaim cloud storage, reduce clutter, and create a reliable local archive.
CommandDescription/126mail setupConfigure IMAP credentials and verify connection/126mail backupDownload emails to local storage (supports resume)/126mail classifyScan and classify all emails by sender domain/126mail cleanupInteractively bulk-delete ads/subscriptions/126mail stripDownload large attachments locally, then replace originals with lightweight stubs on server/126mail statusShow current mailbox stats and cleanup progress
Provide your credentials when prompted:
text
MAIL126_ADDRESS=your_email@126.com
MAIL126_AUTH_CODE=your_authorization_code
Run /126mail setup to test the IMAP connection. The skill will:
imap.126.com:993 (SSL)126.com IMAP has several quirks. This skill handles them automatically, but here is the reference for transparency:
ItemValueServerimap.126.comPort993 (SSL)AuthLOGIN with authorization code (not password)ID Command****REQUIRED — must send ID ("name" "IMAPClient" "version" "1.0.0" ...) after login, or server rejects operations
Chinese folder names are encoded. Common mappings:
Display NameIMAP Name已发送 (Sent)&XfJT0ZAB-草稿箱 (Drafts)&g0l6P3ux-已删除 (Trash)&XfJSIJZk-垃圾邮件 (Spam)&V4NXPpCuTvY-
OperationLimitFETCH (download)4GB per session before throttlingSEARCH, SIZE queriesUnlimitedUID SEARCH ALL3 secondsUID SEARCH FROM35 seconds per queryUID COPY0.25 sec/email, optimal batch = 50
This is the most important lesson. IMAP sequence numbers shift after any deletion. If you delete email #5, then email #6 becomes #5, #7 becomes #6, etc. Using sequence numbers after deletions WILL operate on wrong emails. Always use UID FETCH, UID STORE, UID COPY, UID SEARCH.
/126mail backup)#message.eml with a _meta.json sidecarbackup_dir/folder_name/UID_subject/_download_progress.jsonDecisionOptionsRecommendationWhich folders to back upAll / INBOX only / CustomStart with INBOX + SentInclude attachmentsYes / Skip large onesYes (they're your data)Batch size100-500 emails500 (maximize before rate limit)
/126mail classify)#all_emails_meta.json (full index) and email_classification.jsonDecisionOptionsRecommendationClassification strictnessAggressive / ConservativeConservative — review before deleteTime cutoff for deletionAll time / Before 2025 / CustomBefore current year (keep recent)Domain whitelistAuto / Manual reviewAlways manually review KEEP list
/126mail cleanup)#UID STORE +FLAGS \Deleted + EXPUNGEtext
INBOX emails ──UID COPY──> 广告邮件夹 (staging copy)
│
└── UID STORE \Deleted + EXPUNGE (remove from INBOX)
User verifies in web client...
广告邮件夹 ──permanent delete──> Gone (only after user confirms)
DecisionOptionsRecommendationDeletion scopeBy domain / By category / By dateBy domain — most preciseStaging folderCreate new / Use existingCreate "广告邮件" for reviewWhen to purge stagingImmediately / After 7 days / ManualManual — check in web client firstVerification sample size5 / 10 / 2010 random emails
text
linkedin.com, crunchbase.com, amazon.com, jd.com,
service.taobao.com, airbnb.com, booking.com, uber.com,
ctrip.com, trip.com, godaddy.com, coursera.org,
service.netease.com, insideapple.apple.com,
accounts.google.com, intl.paypal.com, citibank.com,
mail.meituan.com, sf-express.com, ...
text
svb.com, gusto.com, berkeley.edu, alibaba-inc.com,
live.com, 139.com, pku.edu.cn, ...
Always let the user review and customize these lists based on their own email history.
/126mail strip)#Phase A — Download Only (read-only, no server changes)
_meta.json) for each_progress.jsonPhase B — Strip and Replace (destructive, requires explicit confirmation)
[附件已移除 - 已备份到本地] with file list and original sizeBeforeAfterSaved70 emails @ 50-200MB each70 emails @ 5-50KB each~3.4GB
DecisionOptionsRecommendationSize threshold10MB / 20MB / 50MB / 100MB50MB (best ROI)Which foldersAll / INBOX onlyAll foldersVerify downloads before strippingYes / SkipAlways Yes — Phase B is destructive
ErrorCauseResolutionLOGIN failedWrong auth code or IMAP not enabledRe-generate authorization code at 126 settingsID command rejectedMissing ID command after loginSkill sends ID automatically — report if this occursFETCH timeoutRate limit hit (~4GB)Save progress, wait 1-2 hours, resumeBAD commandFolder name encoding wrongSkill uses correct Modified UTF-7Sequence number mismatchUsed sequence instead of UIDSkill always uses UID operations
All operations save progress to JSON files:
_download_progress.json — Full backup progress_progress.json — Large email strip progresscleanup_progress.md — Human-readable summaryThis means every operation is resumable. If your connection drops, rate limit hits, or you close your laptop — just run the command again and it picks up where it left off.
/126mail setup — Connect and verify/126mail status — See current mailbox state/126mail backup — Full local backup (run multiple times if rate-limited)/126mail classify — Index and classify all emails/126mail cleanup — Review and bulk-delete ads/subscriptions/126mail strip — Reclaim space from large attachments/126mail status — Verify resultsimaplib and email (standard library only, no pip dependencies)