⚙️ TempMail Setup Guide

Installation & Configuration - Email Piping Method

System Overview

Requirements

Email Method

⚡ Email Piping (Real-time) Email langsung di-pipe ke PHP script - instant tanpa delay!

File Structure

📦 public_html/ ├── api.php # API endpoint ├── config.php # Configuration ├── install.php # Installer ├── mail-receiver.php # Piping receiver ⚡ ├── cleanup.php # Cleanup cron └── temp-email.php # Web UI

Configuration

Edit config.php:

Database

// Database Configuration define( 'DB_HOST', 'localhost' ); define( 'DB_NAME', 'tempmail' ); define( 'DB_USER', 'YOUR_USERNAME' // dari cPanel MySQL ); define( 'DB_PASS', 'YOUR_PASSWORD' // dari cPanel MySQL );

Single Domain

// Domain Configuration define( 'EMAIL_DOMAIN', 'yourdomain.com' ); define( 'ALLOWED_DOMAINS', [ 'yourdomain.com' ] );

Multiple Domain (Optional)

// Multiple Domain Configuration define( 'EMAIL_DOMAIN', 'suksma.id' ); define( 'ALLOWED_DOMAINS', [ 'suksma.id', 'tempmail.net', 'disposable.email' ] );
💡 Multiple Domain Setup piping untuk setiap domain. Satu script handle semua domain.

Config Reference

ConstantDescriptionExample
DB_HOSTDatabase hostlocalhost
DB_NAMEDatabase nametempmail
DB_USERDB usernameuser_tempmail
EMAIL_DOMAINDefault domainsuksma.id

Installation

Step 1: Upload Files
  • Login ke cPanel
  • File Manager → public_html
  • Upload semua file
  • Set permissions 644
Step 2: Create Database
  • cPanel → MySQL Databases
  • Create Database: tempmail
  • Create User + Password
  • Add User (ALL PRIVILEGES)
Step 3: Run Installer

Akses: https://yourdomain.com/install.php

  • DB Host: localhost
  • DB Name: tempmail
  • DB User & Pass (dari cPanel)
  • Domain: yourdomain.com
  • Klik Install
⚠️ Important Hapus install.php setelah berhasil!

Setup Email Piping

Configure Default Address

✅ What This Does Email ke *@domain.com langsung masuk ke mail-receiver.php real-time!

Multiple Domain

Ulangi untuk setiap domain:

# Domain 1: suksma.id Default Address → Pipe to a Program Path: usr/bin/php public_html/mail-receiver.php # Domain 2: tempmail.net Default Address → Pipe to a Program Path: usr/bin/php public_html/mail-receiver.php # Domain 3: disposable.email Default Address → Pipe to a Program Path: usr/bin/php public_html/mail-receiver.php
💡 Path Options Relative: usr/bin/php public_html/mail-receiver.php
Absolute: /usr/bin/php /home/user/public_html/mail-receiver.php

Cron Job (Cleanup Only)

📌 Note Email sudah real-time via piping. Cron hanya untuk cleanup.

Setup

Command (PHP)

# Cron Expression: Every day at 2 AM 0 2 * * * /usr/bin/php /home/USERNAME/public_html/cleanup.php # Breakdown: # 0 = minute (0) # 2 = hour (2 AM) # * = day of month (every day) # * = month (every month) # * = day of week (every day)
⚠️ Replace Ganti USERNAME dengan cPanel username

Alternative (wget)

# Using wget to trigger cleanup via HTTP 0 2 * * * wget -q -O - https://yourdomain.com/cleanup.php >/dev/null 2>&1 # Options: # -q = quiet mode # -O - = output to stdout # >/dev/null = discard output # 2>&1 = redirect errors to output

Testing

1. Web Interface

Akses: https://yourdomain.com/temp-email.php

2. Custom Email

3. Email Receiving

4. API Test

# Test 1: Generate Random Email curl https://yourdomain.com/api.php/generate # Response: { "success": true, "email": "budipratama123@suksma.id", "username": "budipratama123", "domain": "suksma.id", "expires_at": "2026-01-25 15:30:00" } # Test 2: Generate Custom Email curl https://yourdomain.com/api.php/generate?username=testuser # Response: { "success": true, "email": "testuser@suksma.id", "username": "testuser", "domain": "suksma.id", "expires_at": "2026-01-25 15:30:00" }
✅ All Pass? Selamat! TempMail berhasil terinstall!

Troubleshooting

❌ Database Connection Failed
  • Check DB_USER, DB_PASS di config.php
  • Verify database exists di cPanel
  • Check user privileges (ALL)
❌ Email Tidak Masuk
  • Check Default Address di cPanel (piping set?)
  • Verify path mail-receiver.php benar
  • Check permissions: chmod 755 mail-receiver.php
  • Lihat error_log di cPanel
❌ Username Reserved

Username 'admin', 'info', 'root' dll di-block.

Gunakan username lain atau edit list di api.php

❌ Cron Tidak Jalan
  • Check PHP path: which php
  • Gunakan absolute path
  • Test manual: php cleanup.php
  • Alternative: wget/curl method

Debug Mode

// Enable error reporting untuk debugging error_reporting( E_ALL ); ini_set( 'display_errors', 1 ); ini_set( 'log_errors', 1 ); ini_set( 'error_log', '/path/to/error.log' );
⚠️ Disable di production! Set display_errors = 0 setelah development selesai