diff --git a/docs/drivers/drivers.md b/docs/drivers/drivers.md index d3896e0..d924ddb 100644 --- a/docs/drivers/drivers.md +++ b/docs/drivers/drivers.md @@ -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. diff --git a/src/Http/Requests/MailCareRequest.php b/src/Http/Requests/MailCareRequest.php index fd4405b..0e2215d 100644 --- a/src/Http/Requests/MailCareRequest.php +++ b/src/Http/Requests/MailCareRequest.php @@ -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()); } }