Email OTP Skill
A skill for creating temporary email addresses and automatically extracting OTP codes and validation links from incoming emails. Uses the free mail.tm API (no API key required).
When to Use This Skill
Invoke this skill when the user asks to:
- - Create a temporary email address
- Get a disposable email for signup/verification
- Check for OTP (one-time password) codes
- Wait for email verification links
- Monitor an inbox for authentication codes
Quick Start
CODEBLOCK0
Commands
Create Account
CODEBLOCK1
Options:
- -
-e, --email ADDRESS - Custom full email address - INLINECODE1 - Specific domain to use
- INLINECODE2 - Account password (auto-generated if not specified)
- INLINECODE3 - Output as JSON
Example:
CODEBLOCK2
Check for OTP/Links
CODEBLOCK3
Options:
- -
--timeout SECONDS - Max seconds to wait (default: 300) - INLINECODE5 - Poll interval in seconds (default: 3)
- INLINECODE6 - Only accept emails from this sender
- INLINECODE7 - Only accept emails with this in subject
- INLINECODE8 - Custom regex pattern for OTP extraction
- INLINECODE9 - Exit after first OTP found
- INLINECODE10 - Output messages as JSON
Examples:
CODEBLOCK4
List Account and Messages
CODEBLOCK5
Shows the current account details and all messages in the inbox with extracted links.
List Available Domains
CODEBLOCK6
Output Files
When an OTP or link is found, the script automatically saves them to the unified state directory:
- -
~/.tempmail_otp/last_otp - Contains the last extracted OTP code - INLINECODE12 - Contains the first interesting validation link found
- INLINECODE13 - Account credentials (JWT token, email, password)
All state files are stored in ~/.tempmail_otp/ with restricted permissions (0600).
OTP Detection Patterns
The script automatically detects OTP codes using these patterns:
- - 6-8 digit numbers (most common)
- 4 digit numbers
- "code: XXXXXX" format
- "verification: XXXXXX" format
- "otp: XXXXXX" format
Link Extraction
The script extracts all HTTP/HTTPS links from email HTML, filtering out:
- - Unsubscribe links
- Tracking links
- Image files (.png, .jpg, .gif)
State Management
All state is stored in a unified directory: INLINECODE15
- -
account.json - Account credentials and JWT token (created by create command) - INLINECODE18 - Most recent OTP code extracted (created by
check command) - INLINECODE20 - First validation link extracted (created by
check command)
Files have restricted permissions (0600) for security. The check and list commands automatically use stored credentials.
Design Rationale
The unified state directory follows best practices for CLI tools:
- 1. No project pollution - No temporary files are created in your working directory
- Predictable location - All state is in one place, easy to find and clean up
- Cross-session persistence - Works from any directory on your system
- Permission safety - Sensitive credentials have proper file permissions
To reset all state: INLINECODE24
Typical Workflow
- 1. Create account - Generate a new temporary email address
- Use email - Provide the email during service signup
- Monitor inbox - Run the check command to wait for OTP/link
- Extract code - OTP is automatically displayed and saved to INLINECODE25
- Verify - Use the OTP or link to complete verification
Example Session
CODEBLOCK7
Error Handling
- - If email address is already taken, the script automatically retries with a new username
- Network errors are logged and the script continues polling
- Invalid account state prompts to recreate the account
API
This skill uses the mail.tm REST API:
- - Base URL: INLINECODE26
- Authentication: JWT Bearer token
- No API key required
Notes
- - Temporary emails may expire after inactivity periods
- Some services may block temporary email domains
- The script automatically handles account creation and JWT token management
- OTP patterns cover most common formats, but custom regex can be provided via INLINECODE27
电子邮件OTP技能
用于创建临时电子邮件地址并自动从收到的邮件中提取OTP代码和验证链接的技能。使用免费的mail.tm API(无需API密钥)。
何时使用此技能
当用户要求以下操作时调用此技能:
- - 创建临时电子邮件地址
- 获取用于注册/验证的一次性邮箱
- 检查OTP(一次性密码)代码
- 等待电子邮件验证链接
- 监控收件箱中的验证码
快速开始
bash
创建新的临时邮箱
python3 scripts/tempmail_otp.py create
监控OTP代码(5分钟超时)
python3 scripts/tempmail_otp.py check
列出当前账户和邮件
python3 scripts/tempmail_otp.py list
命令
创建账户
bash
python3 scripts/tempmail_otp.py create [选项]
选项:
- - -e, --email 地址 - 自定义完整电子邮件地址
- -d, --domain 域名 - 指定使用的域名
- -p, --password 密码 - 账户密码(未指定时自动生成)
- --json - 以JSON格式输出
示例:
bash
python3 scripts/tempmail_otp.py create --domain marcilzo.com
检查OTP/链接
bash
python3 scripts/tempmail_otp.py check [选项]
选项:
- - --timeout 秒数 - 最大等待秒数(默认:300)
- --poll 秒数 - 轮询间隔秒数(默认:3)
- --sender 邮箱 - 仅接受来自此发件人的邮件
- --subject 文本 - 仅接受主题包含此文本的邮件
- --pattern 正则表达式 - 用于OTP提取的自定义正则表达式模式
- --once - 找到第一个OTP后退出
- --json - 以JSON格式输出消息
示例:
bash
等待最多2分钟获取OTP
python3 scripts/tempmail_otp.py check --timeout 120
仅接受来自noreply@example.com的邮件
python3 scripts/tempmail_otp.py check --sender noreply@example.com
找到OTP后立即退出
python3 scripts/tempmail_otp.py check --once
列出账户和邮件
bash
python3 scripts/tempmail_otp.py list
显示当前账户详情和收件箱中所有邮件及其提取的链接。
列出可用域名
bash
python3 scripts/tempmail_otp.py domains [--json]
输出文件
当找到OTP或链接时,脚本会自动将其保存到统一状态目录:
- - ~/.tempmailotp/lastotp - 包含最后提取的OTP代码
- ~/.tempmailotp/lastlink - 包含找到的第一个有效验证链接
- ~/.tempmail_otp/account.json - 账户凭证(JWT令牌、邮箱、密码)
所有状态文件存储在~/.tempmail_otp/目录中,权限受限(0600)。
OTP检测模式
脚本使用以下模式自动检测OTP代码:
- - 6-8位数字(最常见)
- 4位数字
- code: XXXXXX格式
- verification: XXXXXX格式
- otp: XXXXXX格式
链接提取
脚本从邮件HTML中提取所有HTTP/HTTPS链接,并过滤掉:
- - 退订链接
- 跟踪链接
- 图片文件(.png、.jpg、.gif)
状态管理
所有状态存储在统一目录中:~/.tempmail_otp/
- - account.json - 账户凭证和JWT令牌(由create命令创建)
- lastotp - 最近提取的OTP代码(由check命令创建)
- lastlink - 提取的第一个验证链接(由check命令创建)
文件权限受限(0600)以确保安全。check和list命令自动使用存储的凭证。
设计原理
统一状态目录遵循CLI工具的最佳实践:
- 1. 无项目污染 - 不会在工作目录中创建临时文件
- 可预测的位置 - 所有状态集中在一处,易于查找和清理
- 跨会话持久性 - 可在系统的任何目录中使用
- 权限安全 - 敏感凭证具有适当的文件权限
重置所有状态:rm -rf ~/.tempmail_otp/
典型工作流程
- 1. 创建账户 - 生成新的临时电子邮件地址
- 使用邮箱 - 在服务注册时提供该邮箱
- 监控收件箱 - 运行检查命令等待OTP/链接
- 提取代码 - OTP自动显示并保存到~/.tempmailotp/lastotp
- 验证 - 使用OTP或链接完成验证
示例会话
bash
创建临时邮箱
$ python3 scripts/tempmail_otp.py create
邮箱:a3b7c9d4@marcilzo.com
密码:f8e4d2a1-1234-5678-9abc-123456789abc
域名:marcilzo.com
账户已保存到 /home/user/.tempmail_otp/account.json
在另一个终端中等待OTP
$ python3 scripts/tempmail_otp.py check --once
正在监控:a3b7c9d4@marcilzo.com
超时时间:300秒 | 轮询间隔:3秒
📧 新邮件来自:noreply@service.com
主题:您的验证码
✅ 找到OTP:842197
OTP已保存到 /home/user/.tempmailotp/lastotp
错误处理
- - 如果邮箱地址已被占用,脚本会自动使用新用户名重试
- 网络错误会被记录,脚本继续轮询
- 无效的账户状态会提示重新创建账户
API
此技能使用mail.tm REST API:
- - 基础URL:https://api.mail.tm
- 认证方式:JWT Bearer令牌
- 无需API密钥
注意事项
- - 临时邮箱可能因长时间不活跃而过期
- 某些服务可能会屏蔽临时邮箱域名
- 脚本自动处理账户创建和JWT令牌管理
- OTP模式覆盖大多数常见格式,但可通过--pattern提供自定义正则表达式