File size: 4,805 Bytes
115e31e
 
 
7c1d695
 
115e31e
 
 
 
7290d7a
 
6343462
7290d7a
bb0e8fb
7290d7a
6343462
bbc9b9b
6343462
 
 
7290d7a
 
 
 
6343462
7290d7a
6343462
 
7290d7a
6343462
 
bbc9b9b
7290d7a
 
6343462
bb0e8fb
6343462
 
 
 
bb0e8fb
7290d7a
 
6343462
7290d7a
 
 
6343462
 
 
7290d7a
6343462
 
bb0e8fb
 
7290d7a
bb0e8fb
7290d7a
bb0e8fb
 
 
6343462
 
bb0e8fb
6343462
 
 
bb0e8fb
6343462
bbc9b9b
 
6343462
7290d7a
bb0e8fb
7290d7a
6343462
7290d7a
6343462
 
 
 
 
7290d7a
 
6343462
 
7290d7a
 
 
 
 
 
6343462
bbc9b9b
bb0e8fb
6343462
 
bbc9b9b
 
7290d7a
6343462
7290d7a
6343462
7290d7a
 
 
 
 
6343462
 
 
 
 
 
 
 
bbc9b9b
6343462
 
 
 
 
 
 
7290d7a
6343462
bb0e8fb
 
7290d7a
 
bb0e8fb
7290d7a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
---
title: Outlook2API
emoji: πŸ“§
colorFrom: red
colorTo: yellow
sdk: docker
app_port: 7860
---

# Outlook2API

Mail.tm-compatible REST API for Outlook/Hotmail/Live accounts with admin panel and batch account registration.

## Features

- **Mail API** β€” Mail.tm-compatible Hydra API endpoints (domains, accounts, token, messages)
- **Admin Panel** β€” Web UI for account management, bulk import/export, webmail with compose/reply, stats dashboard
- **Batch Registration** β€” Automated Outlook account creation via GitHub Actions
- **CI Auto-Import** β€” Registered accounts automatically imported to admin panel
- **Verification Code Extraction** β€” `GET /messages/{id}/code` extracts OTP from emails

## Quick Start

```bash
# Install dependencies
pip install -r requirements-api.txt

# Start the API server
python -m outlook2api.app

# Open http://localhost:8001 for homepage
# Open http://localhost:8001/admin for admin panel (default password: bk@3fd3E)
```

### Docker

```bash
cp .env.example .env
docker compose up -d outlook2api
```

## API Endpoints

### Mail API (Mail.tm-compatible)

| Method | Path | Auth | Description |
|--------|------|------|-------------|
| GET | `/domains` | No | List supported email domains |
| POST | `/accounts` | No | Register account (validates IMAP) |
| POST | `/token` | No | Get JWT bearer token |
| GET | `/me` | Bearer | Current user info |
| GET | `/messages` | Bearer | List inbox messages |
| GET | `/messages/{id}` | Bearer | Get single message |
| GET | `/messages/{id}/code` | Bearer | Extract verification code |
| DELETE | `/accounts/me` | Bearer | Delete account |

### Admin API

| Method | Path | Description |
|--------|------|-------------|
| POST | `/admin/api/login` | Login (returns token) |
| GET | `/admin/api/stats` | Dashboard statistics |
| GET | `/admin/api/accounts` | List accounts (search, filter, paginate) |
| POST | `/admin/api/accounts` | Add single account |
| POST | `/admin/api/accounts/bulk` | Bulk import (`["email:pass",...]`) |
| POST | `/admin/api/accounts/upload` | File upload (email:password per line) |
| PATCH | `/admin/api/accounts/{id}` | Toggle active / update notes |
| DELETE | `/admin/api/accounts/{id}` | Delete account |
| GET | `/admin/api/accounts/{id}/password` | Reveal password |
| GET | `/admin/api/accounts/{id}/messages` | Fetch messages via IMAP |
| POST | `/admin/api/accounts/{id}/send` | Send email via SMTP |
| GET | `/admin/api/export` | Export all active accounts |

## CI Auto-Import

GitHub Actions automatically imports registered accounts to the admin panel.

**Required secrets:**
- `CAPTCHA_CLIENT_KEY` β€” YesCaptcha/CapSolver API key
- `PROXY_URL` β€” HTTP/SOCKS5 proxy
- `OUTLOOK2API_URL` β€” Admin panel URL (e.g., `https://ohmyapi-outlook2api.hf.space`)
- `ADMIN_PASSWORD` β€” Admin panel password

```bash
# Trigger registration + auto-import
gh workflow run register-outlook.yml -f count=5 -f threads=1
```

## Environment Variables

| Name | Default | Description |
|------|---------|-------------|
| `OUTLOOK2API_JWT_SECRET` | `change-me-in-production` | JWT signing secret |
| `ADMIN_PASSWORD` | `bk@3fd3E` | Admin panel password |
| `DATABASE_URL` | `sqlite+aiosqlite:///./data/outlook2api.db` | Database URL |
| `OUTLOOK2API_HOST` | `0.0.0.0` | API bind host |
| `OUTLOOK2API_PORT` | `8001` | API bind port |
| `OUTLOOK_SMTP_HOST` | `smtp-mail.outlook.com` | SMTP server host |
| `OUTLOOK_SMTP_PORT` | `587` | SMTP server port |

## HuggingFace Deployment

Deployed at: **https://ohmyapi-outlook2api.hf.space**

## Project Structure

```
outlook2api/
β”œβ”€β”€ outlook2api/               # FastAPI mail API + admin
β”‚   β”œβ”€β”€ app.py                 # Application entry point
β”‚   β”œβ”€β”€ routes.py              # Mail.tm-compatible API routes
β”‚   β”œβ”€β”€ admin_routes.py        # Admin API routes
β”‚   β”œβ”€β”€ database.py            # SQLAlchemy models (Account)
β”‚   β”œβ”€β”€ auth.py                # JWT auth helpers
β”‚   β”œβ”€β”€ config.py              # Environment config
β”‚   β”œβ”€β”€ outlook_imap.py        # IMAP client
β”‚   β”œβ”€β”€ outlook_smtp.py        # SMTP client (send email)
β”‚   β”œβ”€β”€ store.py               # Legacy JSON file store
β”‚   └── static/                # Frontend
β”‚       β”œβ”€β”€ index.html         # Homepage
β”‚       └── admin.html         # Admin panel
β”œβ”€β”€ register/                  # Batch registration
β”‚   β”œβ”€β”€ outlook_register.py    # DrissionPage registrar
β”‚   └── captcha.py             # FunCaptcha cloud solver
β”œβ”€β”€ .github/workflows/
β”‚   └── register-outlook.yml   # CI: register + auto-import
β”œβ”€β”€ Dockerfile.api
β”œβ”€β”€ Dockerfile.register
β”œβ”€β”€ docker-compose.yml
β”œβ”€β”€ requirements-api.txt
└── requirements-register.txt
```