diff --git a/README.md b/README.md index 36bc537..c591a9e 100644 --- a/README.md +++ b/README.md @@ -61,7 +61,7 @@ php artisan vendor:publish --tag="mails-migrations" php artisan migrate ``` -Add the API key of your email service provider to the `config/services.php` file in your Laravel project, currently we only support Postmark: +Add the API key of your email service provider to the `config/services.php` file in your Laravel project, currently we only support Postmark and Mailgun: ``` [ diff --git a/src/Actions/LogMail.php b/src/Actions/LogMail.php index 3dcf485..f4eaf31 100644 --- a/src/Actions/LogMail.php +++ b/src/Actions/LogMail.php @@ -101,7 +101,7 @@ protected function getCustomUuid(MessageSending|MessageSent $event): ?string protected function getAddressesValue(array $address): ?Collection { $addresses = collect($address) - ->flatMap(fn (Address $address) => [$address->getAddress() => $address->getName() === '' ? null : $address->getName()]); + ->flatMap(fn(Address $address) => [$address->getAddress() => $address->getName() === '' ? null : $address->getName()]); return $addresses->count() > 0 ? $addresses : null; } @@ -125,6 +125,6 @@ public function collectAttachments($mail, $attachments): void public function saveAttachment($attachmentModel, $attachment): void { Storage::disk($attachmentModel->disk) - ->put($attachment->storagePath, $attachment->getBody(), 'private'); + ->put($attachmentModel->storagePath, $attachment->getBody(), 'private'); } } diff --git a/src/Drivers/MailgunDriver.php b/src/Drivers/MailgunDriver.php index ea9a13d..5d7d393 100644 --- a/src/Drivers/MailgunDriver.php +++ b/src/Drivers/MailgunDriver.php @@ -15,6 +15,8 @@ public function registerWebhooks($components): void $apiKey = config('services.mailgun.secret'); $domain = config('services.mailgun.domain'); + $scheme = config('services.mailgun.scheme', 'https'); + $endpoint = config('services.mailgun.endpoint', 'api.mailgun.net'); $webhookUrl = URL::signedRoute('mails.webhook', ['provider' => 'mailgun']); @@ -49,7 +51,7 @@ public function registerWebhooks($components): void foreach ($events as $event) { $response = Http::withBasicAuth('api', $apiKey) ->asMultipart() - ->post("https://api.mailgun.net/v3/domains/$domain/webhooks", [ + ->post("$scheme://$endpoint/v3/domains/$domain/webhooks", [ 'id' => $event, 'url' => $webhookUrl, ]); diff --git a/src/Models/Mail.php b/src/Models/Mail.php index 1e8d74b..bdd3f88 100644 --- a/src/Models/Mail.php +++ b/src/Models/Mail.php @@ -37,6 +37,13 @@ * * @method static Builder forUuid(string $uuid) * @method static Builder forMailClass(string $mailClass) + * @method static Builder sent() + * @method static Builder delivered() + * @method static Builder opened() + * @method static Builder clicked() + * @method static Builder softBounced() + * @method static Builder hardBounced() + * @method static Builder unsent() */ class Mail extends Model {