Oke, ini tutorial lengkap deploy Temp Mail API di Cloudflare Workers: ๐Ÿ“ง Tutorial Deploy Temp Mail API 1. Buat D1 Database Via Dashboard: 1. Buka Cloudflare Dashboard 2. Klik Workers & Pages โ†’ D1 SQL Database 3. Klik Create Database 4. Nama: MAIL_DB 5. Klik Create Via CLI: ```bash wrangler d1 create MAIL_DB ``` --- 2. Buat Tables Di dashboard D1 โ†’ klik database MAIL_DB โ†’ tab Console โ†’ paste SQL ini: ```sql CREATE TABLE IF NOT EXISTS accounts ( id TEXT PRIMARY KEY, address TEXT UNIQUE, password TEXT, quota INTEGER DEFAULT 40000000, used INTEGER DEFAULT 0, is_disabled INTEGER DEFAULT 0, is_deleted INTEGER DEFAULT 0, created_at TEXT, updated_at TEXT, expires_at TEXT ); CREATE TABLE IF NOT EXISTS messages ( id TEXT PRIMARY KEY, account_id TEXT, from_address TEXT, from_name TEXT, to_address TEXT, subject TEXT, text_content TEXT, html_content TEXT, intro TEXT, seen INTEGER DEFAULT 0, is_deleted INTEGER DEFAULT 0, has_attachments INTEGER DEFAULT 0, size INTEGER DEFAULT 0, created_at TEXT, updated_at TEXT, expires_at TEXT ); CREATE TABLE IF NOT EXISTS domains ( id TEXT PRIMARY KEY, domain TEXT UNIQUE, is_active INTEGER DEFAULT 1, created_at TEXT ); CREATE INDEX IF NOT EXISTS idx_messages_account ON messages(account_id); CREATE INDEX IF NOT EXISTS idx_accounts_address ON accounts(address); ``` --- 3. Insert Domain Masih di Console, paste: ```sql INSERT OR IGNORE INTO domains (id, domain, is_active, created_at) VALUES ('domain-cair-eu-cc', 'cair.eu.cc', 1, '2026-09-07T00:00:00+00:00'); ``` --- 4. Buat Worker 1. Buka Workers & Pages โ†’ Create โ†’ Create Worker 2. Nama: email 3. Klik Deploy --- 5. Edit Worker Code 1. Buka worker email 2. Klik Edit Code 3. Hapus semua kode default 4. Paste kode worker yang gua kasih terakhir 5. Klik Save & Deploy --- 6. Bind D1 ke Worker 1. Buka worker email 2. Klik Settings โ†’ Variables 3. Scroll ke D1 Database Bindings 4. Klik Add Binding 5. Variable name: MAIL_DB 6. D1 Database: pilih MAIL_DB 7. Klik Save --- 7. Setup Custom Domain 1. Buka worker email 2. Klik Settings โ†’ Domains & Routes 3. Klik Add โ†’ Custom Domain 4. Masukkan: cair.eu.cc 5. Klik Add --- 8. Setup Email Routing (Buat Terima Email dari Gmail) 1. Buka Cloudflare Dashboard โ†’ klik domain eu.cc 2. Klik Email โ†’ Email Routing 3. Klik Enable Email Routing 4. Ikuti instruksi (tambah MX records otomatis) 5. Klik Email Workers โ†’ Add route 6. Route: cair.eu.cc โ†’ worker email --- 9. Test Test Dashboard: Buka browser โ†’ https://cair.eu.cc Test API: ```bash # Get domains curl -X GET "https://cair.eu.cc/domains" # Create account curl -X POST "https://cair.eu.cc/accounts" \ -H "Content-Type: application/json" \ -d '{"address":"test@cair.eu.cc","password":"Password123!"}' # Get token curl -X POST "https://cair.eu.cc/token" \ -H "Content-Type: application/json" \ -d '{"address":"test@cair.eu.cc","password":"Password123!"}' # Get messages curl -X GET "https://cair.eu.cc/messages" \ -H "Authorization: Bearer TOKEN" ``` --- 10. Setup Custom Domain api.cair.eu.cc (Opsional) Kalau mau API di subdomain terpisah: 1. Buka worker email โ†’ Settings โ†’ Domains & Routes 2. Add Custom Domain: api.cair.eu.cc Terus update kode worker biar ngecek hostname. Tapi kalau mau simple, cukup pakai cair.eu.cc untuk semua. --- Selesai! ๐ŸŽ‰ Kalau ada error, cek: ยท Logs tab di worker ยท D1 Console buat cek data masuk ยท Email Routing buat cek email masuk Gas! ๐Ÿ”ฅโ˜•