Skip to content

Update MailCare Request #95

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
14 changes: 11 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
@@ -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": "[email protected]",
"homepage": "https://beyondcode.de",
"role": "Original Developer"
},
{
"name": "Ashraf Vali",
"email": "[email protected]",
"homepage": "https://cubewebsites.com",
"role": "Developer"
}
],
Expand Down
15 changes: 15 additions & 0 deletions docs/drivers/drivers.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
16 changes: 15 additions & 1 deletion docs/getting-started/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
17 changes: 17 additions & 0 deletions src/Drivers/Postal.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace BeyondCode\Mailbox\Drivers;

use BeyondCode\Mailbox\Http\Controllers\MailCareController;
use BeyondCode\Mailbox\Http\Controllers\PostalController;
use Illuminate\Support\Facades\Route;

class Postal implements DriverInterface
{
public function register()
{
Route::prefix(config('mailbox.path'))->group(function () {
Route::post('/postal', PostalController::class);
});
}
}
21 changes: 21 additions & 0 deletions src/Http/Controllers/PostalController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace BeyondCode\Mailbox\Http\Controllers;

use BeyondCode\Mailbox\Facades\Mailbox;
use BeyondCode\Mailbox\Http\Requests\MailCareRequest;
use BeyondCode\Mailbox\Http\Requests\PostalRequest;
use Illuminate\Routing\Controller;

class PostalController extends Controller
{
public function __construct()
{
$this->middleware('laravel-mailbox');
}

public function __invoke(PostalRequest $request)
{
Mailbox::callMailboxes($request->email());
}
}
3 changes: 1 addition & 2 deletions src/Http/Requests/MailCareRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably this would do as well:

Suggested change
return InboundEmail::fromMessage(file_get_contents('php://input'));
return InboundEmail::fromMessage($this->post());

to get all input

}
}
30 changes: 30 additions & 0 deletions src/Http/Requests/PostalRequest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

namespace BeyondCode\Mailbox\Http\Requests;

use BeyondCode\Mailbox\InboundEmail;
use Carbon\Carbon;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Validator;

class PostalRequest extends FormRequest
{
public function validator()
{
return Validator::make($this->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'));
}

}
5 changes: 5 additions & 0 deletions src/MailboxManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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'];
Expand Down