← Trang chủ

Temp Mail API v1

Base URL: https://vietpham.id.vn/api/public

Đã tạo

Requests

🔑 API Token (bắt buộc cho /create)

Token admin và token mua đều dùng cùng cách — header X-API-Token. Admin không giới hạn lượt tạo.

Chưa có token? Mua tại đây

✅ Phiên thử nghiệm đang active

Email:
Token hòm thư:
Còn lại:
SSE:

🌐 Web API (trang chủ / app)

Các endpoint miễn phí cho người dùng web. Base: https://vietpham.id.vn/api/email

POST /api/email/create — Tạo email miễn phí (giới hạn IP)
GET /api/email/{token}/inbox — Danh sách mail (summary)
GET /api/email/{token}/message/{id} — Chi tiết 1 mail
GET /api/email/{token}/status — Trạng thái hòm thư
GET /api/email/{token}/stream — SSE real-time (cần TEMP_MAIL_SSE=true)
POST /api/email/restore-backup — Khôi phục từ backupcode
DELETE /api/email/{token} — Xóa hòm thư

Thanh toán token: https://vietpham.id.vn/api/payment/create-invoice · Xem trang Mua Token

📡 Real-time SSE (nhận mail tức thì)

Khi có mail mới, server push ngay full nội dung — không cần poll. Dùng sau khi tạo email và có token hòm thư.

⚠️ Localhost: dùng polling 2s thay SSE — php artisan serve chỉ 1 thread, SSE sẽ chặn mọi API khác (treo 30–60s).

// JavaScript — EventSource
const es = new EventSource('https://vietpham.id.vn/api/public/email/YOUR_EMAIL_TOKEN/stream');

es.addEventListener('snapshot', e => {
  const data = JSON.parse(e.data);
  console.log('Inbox ban đầu:', data.messages); // full body_html + body_text
});

es.addEventListener('message', e => {
  const mail = JSON.parse(e.data);
  console.log('Mail mới:', mail.subject, mail.body_html);
});

es.addEventListener('heartbeat', () => {});