diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 552b207d..a458488d 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -17,6 +17,7 @@ jobs: MAILGUN_API_KEY: ${{ secrets.MAILGUN_API_KEY }} MAILGUN_DOMAIN: ${{ secrets.MAILGUN_DOMAIN }} SENDGRID_API_KEY: ${{ secrets.SENDGRID_API_KEY }} + MANDRILL_API_KEY: ${{ secrets.MANDRILL_API_KEY }} FCM_SERVER_KEY: ${{ secrets.FCM_SERVER_KEY }} FCM_SERVER_TO: ${{ secrets.FCM_SERVER_TO }} TWILIO_ACCOUNT_SID: ${{ secrets.TWILIO_ACCOUNT_SID }} diff --git a/docker-compose.yml b/docker-compose.yml index 80d626d9..ca2fb225 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,6 +6,7 @@ services: - MAILGUN_API_KEY - MAILGUN_DOMAIN - SENDGRID_API_KEY + - MANDRILL_API_KEY - FCM_SERVER_KEY - FCM_SERVER_TO - TWILIO_ACCOUNT_SID diff --git a/src/Utopia/Messaging/Adapters/Email/Mandrill.php b/src/Utopia/Messaging/Adapters/Email/Mandrill.php new file mode 100644 index 00000000..b65ab731 --- /dev/null +++ b/src/Utopia/Messaging/Adapters/Email/Mandrill.php @@ -0,0 +1,69 @@ +request( + method: 'POST', + url: 'https://mandrillapp.com/api/1.0/messages/send', + headers: [ + 'Content-Type: application/json', + ], + body: \json_encode([ + "key" => $this->apiKey, + "message" => [ + "subject" => $message->getSubject(), + "html" => $message->isHTML() ? $message->getContent() : null, + "text" => $message->isHTML() ? null : $message->getContent(), + "from_email" => $message->getFrom(), + "to" => \array_map( + fn ($to) => ['email' => $to], + $message->getTo() + ), + ] + ]), + ); + } +} diff --git a/tests/e2e/Email/MandrillTest.php b/tests/e2e/Email/MandrillTest.php new file mode 100644 index 00000000..680f3ecb --- /dev/null +++ b/tests/e2e/Email/MandrillTest.php @@ -0,0 +1,38 @@ +send($message))[0]; + + $this->assertArrayHasKey('_id',$response); + $this->assertArrayHasKey('email',$response); + $this->assertArrayHasKey('status',$response); + $this->assertArrayHasKey('reject_reason',$response); + $this->assertArrayHasKey('queued_reason',$response); + } +}