diff --git a/README.md b/README.md index ffe1a31..e84789a 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,5 @@ # Laravel Mailbox 📬 -[![Latest Version on Packagist](https://img.shields.io/packagist/v/beyondcode/laravel-mailbox.svg?style=flat-square)](https://packagist.org/packages/beyondcode/laravel-mailbox) -[![Build Status](https://img.shields.io/travis/beyondcode/laravel-mailbox/master.svg?style=flat-square)](https://travis-ci.org/beyondcode/laravel-mailbox) -[![Quality Score](https://img.shields.io/scrutinizer/g/beyondcode/laravel-mailbox.svg?style=flat-square)](https://scrutinizer-ci.com/g/beyondcode/laravel-mailbox) -[![Total Downloads](https://img.shields.io/packagist/dt/beyondcode/laravel-mailbox.svg?style=flat-square)](https://packagist.org/packages/beyondcode/laravel-mailbox) - Handle incoming emails in your Laravel application. ``` php @@ -16,17 +11,24 @@ Mailbox::from('{username}@gmail.com', function (InboundEmail $email, $username) }); ``` -[![https://phppackagedevelopment.com](https://beyondco.de/courses/phppd.jpg)](https://phppackagedevelopment.com) - -If you want to learn how to create reusable PHP packages yourself, take a look at my upcoming [PHP Package Development](https://phppackagedevelopment.com) video course. +## Installation +As this is a fork of beyondcode/laravel-mailbox, we need to tell composer to use the fork: +Add the following section to your composer.json: -## Installation +``` + "repositories": [ + { + "type": "vcs", + "url": "https://github.com/cubewebsites/laravel-mailbox" + } + ], +``` -You can install the package via composer: +Then install the package. This should install the cubewebsites fork of laravel-mailbox ```bash -composer require beyondcode/laravel-mailbox +composer require cubewebsites/laravel-mailbox ``` ## Usage diff --git a/composer.json b/composer.json index ff2e130..cbd9000 100644 --- a/composer.json +++ b/composer.json @@ -1,17 +1,25 @@ { - "name": "beyondcode/laravel-mailbox", + "name": "cubewebsites/laravel-mailbox", "description": "Handle incoming emails in your Laravel application.", "keywords": [ "beyondcode", - "laravel-mailbox" + "laravel-mailbox", + "inbound-mail", + "email" ], - "homepage": "https://github.com/beyondcode/laravel-mailbox", + "homepage": "https://github.com/cubewebsites/laravel-mailbox", "license": "MIT", "authors": [ { "name": "Marcel Pociot", "email": "marcel@beyondco.de", "homepage": "https://beyondcode.de", + "role": "Original Developer" + }, + { + "name": "Ashraf Vali", + "email": "github@cubewebsites.com", + "homepage": "https://cubewebsites.com", "role": "Developer" } ], diff --git a/docs/drivers/drivers.md b/docs/drivers/drivers.md index d3896e0..9aabe75 100644 --- a/docs/drivers/drivers.md +++ b/docs/drivers/drivers.md @@ -62,6 +62,21 @@ Next you will need to configure MailCare, to send incoming emails to your applic See ["MailCare"](https://mailcare.io) for more information. +## Postal + +https://docs.postalserver.io/ + +Note: This driver requires basic auth setup + +1. Set MAILBOX_DRIVER to `postal` +2. Setup a HTTP Endpoint in Postal: + 1. URL = `https://your-application.com/laravel-mailbox/postal` + 2. Encoding = `Sent in the body as JSON` + 3. Format = `Delivered as the raw message` + 4. Strip Replies = Up to you + 5. Attachments = Doesn't matter because the RAW message always has attachments + 6. Timeout = Tweak if needed + ## Local development / log driver When working locally, you might not want to use real incoming emails while testing your application. Out of the box, this package supports Laravel's "log" mail driver for incoming emails. diff --git a/docs/getting-started/installation.md b/docs/getting-started/installation.md index 36bfc92..b3f6177 100644 --- a/docs/getting-started/installation.md +++ b/docs/getting-started/installation.md @@ -7,8 +7,22 @@ order: 2 Laravel Mailbox can be installed via composer: +As this is a fork of beyondcode/laravel-mailbox, we need to tell composer to use the fork: +Add the following section to your composer.json: + +``` + "repositories": [ + { + "type": "vcs", + "url": "https://github.com/cubewebsites/laravel-mailbox" + } + ], +``` + +Then install the package. This should install the cubewebsites fork of laravel-mailbox + ```bash -composer require beyondcode/laravel-mailbox +composer require cubewebsites/laravel-mailbox ``` The package will automatically register a service provider. diff --git a/src/Drivers/Postal.php b/src/Drivers/Postal.php new file mode 100644 index 0000000..ab56c39 --- /dev/null +++ b/src/Drivers/Postal.php @@ -0,0 +1,17 @@ +group(function () { + Route::post('/postal', PostalController::class); + }); + } +} diff --git a/src/Http/Controllers/PostalController.php b/src/Http/Controllers/PostalController.php new file mode 100644 index 0000000..e3f8579 --- /dev/null +++ b/src/Http/Controllers/PostalController.php @@ -0,0 +1,21 @@ +middleware('laravel-mailbox'); + } + + public function __invoke(PostalRequest $request) + { + Mailbox::callMailboxes($request->email()); + } +} diff --git a/src/Http/Requests/MailCareRequest.php b/src/Http/Requests/MailCareRequest.php index fd4405b..83aecc6 100644 --- a/src/Http/Requests/MailCareRequest.php +++ b/src/Http/Requests/MailCareRequest.php @@ -11,12 +11,11 @@ class MailCareRequest extends FormRequest public function validator() { return Validator::make($this->all(), [ - 'email' => 'required', ]); } public function email() { - return InboundEmail::fromMessage($this->get('email')); + return InboundEmail::fromMessage(file_get_contents('php://input')); } } diff --git a/src/Http/Requests/PostalRequest.php b/src/Http/Requests/PostalRequest.php new file mode 100644 index 0000000..11c93bb --- /dev/null +++ b/src/Http/Requests/PostalRequest.php @@ -0,0 +1,30 @@ +all(), [ + 'id' => 'required', + 'message' => 'required', + 'base64' => 'required', + 'size' => 'required|integer', + ]); + } + + public function email() + { + /** @var InboundEmail $modelClass */ + $modelClass = config('mailbox.model'); + $encoded = filter_var($this->get('base64'), FILTER_VALIDATE_BOOLEAN); + return $modelClass::fromMessage($encoded ? base64_decode($this->get('message')) : $this->get('message')); + } + +} diff --git a/src/MailboxManager.php b/src/MailboxManager.php index afd4901..3aaddb1 100644 --- a/src/MailboxManager.php +++ b/src/MailboxManager.php @@ -5,6 +5,7 @@ use BeyondCode\Mailbox\Drivers\Log; use BeyondCode\Mailbox\Drivers\MailCare; use BeyondCode\Mailbox\Drivers\Mailgun; +use BeyondCode\Mailbox\Drivers\Postal; use BeyondCode\Mailbox\Drivers\Postmark; use BeyondCode\Mailbox\Drivers\SendGrid; use Illuminate\Support\Manager; @@ -41,6 +42,10 @@ public function createPostmarkDriver() return new Postmark; } + public function createPostalDriver() { + return new Postal(); + } + public function getDefaultDriver() { return $this->container['config']['mailbox.driver'];