# πŸ“¬ Email Webhook Receiver for ForwardEmail.net This is a simple PHP webhook endpoint designed to receive incoming emails from [ForwardEmail.net](https://forwardemail.net). The script stores the raw email (`.eml`) files in a structured folder hierarchy and optionally triggers processing scripts per sender. --- ## πŸš€ Features - Accepts HTTP POST requests with raw email JSON data. - Saves each email in a structured folder: `data/emails///` - Supports **custom automation per sender**: Automatically runs `index.sh` or `index.php` in the sender's folder if they exist. - CLI-compatible for testing/debugging. --- ## πŸ“ Folder Structure data/ └── emails/ └── example.com/ └── alice/ β”œβ”€β”€ 65ef123e4c1a0.eml β”œβ”€β”€ index.php # optional └── index.sh # optional --- ## βš™οΈ Installation 1. Clone this repository: ```bash git clone https://github.com/yourusername/email-webhook-receiver.git cd email-webhook-receiver ``` 2. Make sure data/emails/ is writable by your web server: ```bash mkdir -p data/emails chmod -R 775 data/emails ``` 3. Configure your web server (e.g., Apache or Nginx + PHP) to POST email data to this script. βΈ» πŸ“¨ Using with ForwardEmail.net In your ForwardEmail account settings, set the Webhook URL to this script: ``` https://yourdomain.com/path/to/index.php ``` Make sure your server is publicly accessible and uses HTTPS. ForwardEmail will send JSON payloads like: ```json { "raw": "Full raw email as string...", "from": { "value": [ { "address": "alice@example.com" } ] } } ``` βΈ» πŸ§ͺ Local CLI Testing You can test the webhook manually via CLI: ```bash php index.php < sample.json ``` Where sample.json contains a raw test email in JSON format. βΈ» πŸ› οΈ Optional Per-Sender Automation To auto-process incoming emails, create either: β€’ index.sh: a shell script that reads from stdin β€’ index.php: a PHP script that reads from stdin These will be triggered automatically upon email arrival. βΈ» πŸ“¦ Dependencies β€’ PHP 7.0+ β€’ No external dependencies (uses built-in PHP functions) β€’ A small helper file at receiveEmail/lib.php (ensure it’s present) βΈ» πŸ“„ License MIT β€” feel free to modify and use! βΈ» πŸ™‹β€β™‚οΈ Author Developed by Frederico Falcao Questions or ideas? Open an issue or send an email.