Skip to content
Closed
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
48 changes: 48 additions & 0 deletions src/Utopia/Messaging/Adapters/Email/Infobip.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

namespace Utopia\Messaging\Adapters\Email;

use Utopia\Messaging\Messages\Email;
use Utopia\Messaging\Adapters\Email as EmailAdapter;

class Infobip extends EmailAdapter
{
public function __construct(private string $apiKey)
{
}

public function getName(): string
{
return 'Infobip';
}

public function getMaxMessagesPerRequest(): int
{
return 1000;
}

protected function process(Email $message): string
{
return $this->request(
method: 'POST',
url: 'https://3ggzv1.api.infobip.com',
headers: [
'Content-Type: multipart/form-data',
'Authorization: App ' . $this->apiKey,
],
body: \json_encode([
'subject' => $message->getSubject(),
'to' => \array_map(
fn ($to) => ['email' => $to],
$message->getTo()
),
'from' => [
'email' => $message->getFrom(),
],
'attachment' => $message->getAttachments(),
'html' => $message->isHtml(),

]),
);
}
}