Skip to content

Commit

Permalink
Merge pull request #114 from mailcare/fix-mailcare-driver
Browse files Browse the repository at this point in the history
Fix MailCare Driver
  • Loading branch information
mechelon authored Apr 3, 2024
2 parents a3902cf + 4404e66 commit 9c62eed
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
12 changes: 8 additions & 4 deletions docs/drivers/drivers.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,16 @@ Be sure the check the box labeled "Post the raw, full MIME message." when settin

## MailCare

::: warning
To use MailCare with Laravel Mailbox, you will need to generate a random password and store it as the `MAILBOX_HTTP_PASSWORD` environment variable. The default username is "laravel-mailbox", but you can change it using the `MAILBOX_HTTP_USERNAME` environment variable.
:::

You can then set your `MAILBOX_DRIVER` to "mailcare".

Next you will need to configure MailCare, to send incoming emails to your application at `/laravel-mailbox/mailcare`:
- Activate authentication and automation features.
- Create a new automation with the URL `https://your-application.com/laravel-mailbox/mailcare`
- Be sure the check the box labeled "Post the raw, full MIME message."
Next you will need to configure MailCare, to send incoming emails to your application at `/laravel-mailbox/mailcare`.
- Ask support to activate authentication and automation features.
- Create a new automation, if your application is at `https://awesome-laravel.com`, it would be with the URL `https://MAILBOX_HTTP_USERNAME:MAILBOX_HTTP_PASSWORD@awesome-laravel.com/laravel-mailbox/mailcare`
- Be sure the check the box labeled "Post the raw, full MIME message "

See ["MailCare"](https://mailcare.io) for more information.

Expand Down
19 changes: 14 additions & 5 deletions src/Http/Requests/MailCareRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,28 @@

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

class MailCareRequest extends FormRequest
{
public function validator()
public function rules()
{
return Validator::make($this->all(), [
'email' => 'required',
return [
'content_type' => 'required|in:message/rfc2822',
];
}

public function prepareForValidation()
{
$this->merge([
'content_type' => $this->headers->get('Content-type'),
]);
}

public function email()
{
return InboundEmail::fromMessage($this->get('email'));
/** @var InboundEmail $modelClass */
$modelClass = config('mailbox.model');

return $modelClass::fromMessage($this->getContent());
}
}

0 comments on commit 9c62eed

Please sign in to comment.