Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
markvaneijk committed Jan 13, 2025
2 parents a2cc39a + 4184de1 commit 385cf8c
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

```
[
Expand Down
4 changes: 2 additions & 2 deletions src/Actions/LogMail.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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');
}
}
4 changes: 3 additions & 1 deletion src/Drivers/MailgunDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);

Expand Down Expand Up @@ -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,
]);
Expand Down
7 changes: 7 additions & 0 deletions src/Models/Mail.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@
*
* @method static Builder forUuid(string $uuid)
* @method static Builder forMailClass(string $mailClass)
* @method static Builder<static> sent()
* @method static Builder<static> delivered()
* @method static Builder<static> opened()
* @method static Builder<static> clicked()
* @method static Builder<static> softBounced()
* @method static Builder<static> hardBounced()
* @method static Builder<static> unsent()
*/
class Mail extends Model
{
Expand Down

0 comments on commit 385cf8c

Please sign in to comment.