Loading...
Loading...
Read and send email via IMAP/SMTP. Check for new/unread messages, fetch content, search mailboxes, mark as read/unread, and send emails with attachments. Works with any IMAP/SMTP server including Gmail, Outlook, 163.com, vip.163.com, etc.
npx skill4agent add cshen/skills mail139MAIL139_IDyou@139.comMAIL139_TOKENMAIL139_PASSWORDexport MAIL139_ID="you@139.com"
export MAIL139_TOKEN="your-password"{baseDir}/mail139.pypython3 {baseDir}/mail139.py -u "$MAIL139_ID" -p "$MAIL139_TOKEN" <command> [options]
# or simply rely on env defaults:
MAIL139_ID=you@139.com MAIL139_TOKEN=secret python3 {baseDir}/mail139.py <command> [options].emlpython3 {baseDir}/mail139.py -u "$MAIL139_ID" -p "$MAIL139_TOKEN" list-folders--folderpython3 {baseDir}/mail139.py -u "$MAIL139_ID" -p "$MAIL139_TOKEN" fetch [options]| Option | Default | Description |
|---|---|---|
| | IMAP folder to fetch from |
| | Max emails to fetch (newest first) |
| — | Only emails on or after this date |
| — | Filter by text in headers or body |
| | Output format: |
| — | Directory to save output files |
| off | Save attachments (defaults to |
| off | Mark fetched emails as read on the server |
For, files are written to--format eml. If--outputis omitted, the existing--outputdirectory is used. If~/Downloadsdoes not exist, the command exits with an error.~/Downloads
HTML bodies are converted to plain text via(if installed), elsehtml2text, else an internal stripper. No HTML tags appear in printed/JSON bodies.lynx --dump
# Print latest 10 emails to console
python3 {baseDir}/mail139.py -u "$MAIL139_ID" -p "$MAIL139_TOKEN" fetch
# Fetch last 20 emails as JSON
python3 {baseDir}/mail139.py -u "$MAIL139_ID" -p "$MAIL139_TOKEN" fetch \
--limit 20 --format json
# Save as JSON to a directory
python3 {baseDir}/mail139.py -u "$MAIL139_ID" -p "$MAIL139_TOKEN" fetch \
--format json -o ./emails
# Save raw .eml files and extract attachments
python3 {baseDir}/mail139.py -u "$MAIL139_ID" -p "$MAIL139_TOKEN" fetch \
--format eml --save-attachments -o ./emails
# Fetch from Sent folder since a date
python3 {baseDir}/mail139.py -u "$MAIL139_ID" -p "$MAIL139_TOKEN" fetch \
--folder "Sent Messages" --since "01-Jan-2025" --limit 50
# Search for emails containing a keyword
python3 {baseDir}/mail139.py -u "$MAIL139_ID" -p "$MAIL139_TOKEN" fetch \
--search "invoice" --format jsontextjson{
"uid": "1234",
"date": "Mon, 10 Mar 2025 09:00:00 +0800",
"from": "sender@example.com",
"to": "you@139.com",
"subject": "Hello",
"content_type": "text/plain",
"body": "Email body text…",
"attachments": ["report.pdf"]
}emails.json--output--outputeml<uid>.eml--output--sinceDD-Mon-YYYY01-Jan-202515-Mar-2026list-foldersINBOXSent MessagesDraftsDeleted Messages<output>/<uid>_attachments/<filename>--output~/Downloads/<uid>_attachments/--save-attachments--output--output--mark-read--mark-readpython3$MAIL139_ID$MAIL139_TOKEN$MAIL139_PASSWORDMAIL139_IDMAIL139_TOKEN--format textjsoneml--search--sincelist-folders--mark-read--save-attachments--output~/Downloads/<uid>_attachments/--output