From 51036fc414e41ac6ae7dfba152d8a4fc8fd832bf Mon Sep 17 00:00:00 2001 From: Ilhan Ates Date: Mon, 2 Oct 2023 14:56:30 +0300 Subject: [PATCH 1/2] Added MailSlurp Email adapter --- README.md | 2 +- .../Messaging/Adapters/Email/MailSlurp.php | 70 +++++++++++++++++++ tests/e2e/Email/MailSlurpTest.php | 34 +++++++++ 3 files changed, 105 insertions(+), 1 deletion(-) create mode 100644 src/Utopia/Messaging/Adapters/Email/MailSlurp.php create mode 100644 tests/e2e/Email/MailSlurpTest.php diff --git a/README.md b/README.md index d745b630..b4e2e8ac 100644 --- a/README.md +++ b/README.md @@ -87,7 +87,7 @@ $messaging->send($message); - [ ] [Postmark](https://postmarkapp.com/) - [ ] [SparkPost](https://www.sparkpost.com/) - [ ] [SendinBlue](https://www.sendinblue.com/) -- [ ] [MailSlurp](https://www.mailslurp.com/) +- [x] [MailSlurp](https://www.mailslurp.com/) - [ ] [ElasticEmail](https://elasticemail.com/) - [ ] [SES](https://aws.amazon.com/ses/) diff --git a/src/Utopia/Messaging/Adapters/Email/MailSlurp.php b/src/Utopia/Messaging/Adapters/Email/MailSlurp.php new file mode 100644 index 00000000..65922607 --- /dev/null +++ b/src/Utopia/Messaging/Adapters/Email/MailSlurp.php @@ -0,0 +1,70 @@ +inboxId !== null) { + $url .= '?inboxId='.$this->inboxId; + } + return $this->request( + method: 'POST', + url: $url, + headers: [ + 'x-api-key: '.$this->apiKey, + 'Content-Type: application/json', + ], + body: \json_encode([ + 'to' => $message->getTo(), + 'from' => $message->getFrom(), + 'subject' => $message->getSubject(), + 'text' => $message->getContent(), + 'html' => $message->isHtml(), + ]), + ); + } +} diff --git a/tests/e2e/Email/MailSlurpTest.php b/tests/e2e/Email/MailSlurpTest.php new file mode 100644 index 00000000..d5d9c6fa --- /dev/null +++ b/tests/e2e/Email/MailSlurpTest.php @@ -0,0 +1,34 @@ +send($message); + $this->assertEquals($response, ''); + } +} From d4f7b488c5d90c8166427ccd05753e86cb5b8c66 Mon Sep 17 00:00:00 2001 From: Ilhan Ates Date: Mon, 2 Oct 2023 17:24:16 +0300 Subject: [PATCH 2/2] Removed unnecessary comment --- src/Utopia/Messaging/Adapters/Email/MailSlurp.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Utopia/Messaging/Adapters/Email/MailSlurp.php b/src/Utopia/Messaging/Adapters/Email/MailSlurp.php index 65922607..1d2f6d8c 100644 --- a/src/Utopia/Messaging/Adapters/Email/MailSlurp.php +++ b/src/Utopia/Messaging/Adapters/Email/MailSlurp.php @@ -34,9 +34,7 @@ public function getName(): string */ public function getMaxMessagesPerRequest(): int { - // TODO: Find out the actual limit. - // The docs say "limit varies from plan to plan", but I sent them an email asking for clarification and - // will update this when I get a response. + // TODO: Find out the actual limit. The docs say "limit varies from plan to plan" without exact numbers. return 1000; }