diff --git a/docker-compose.yml b/docker-compose.yml index fb87cc43..8f803719 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,6 +2,34 @@ version: '3.9' services: tests: + environment: + - MAILGUN_API_KEY + - MAILGUN_DOMAIN + - POSTMARK_API_KEY + - SENDGRID_API_KEY + - FCM_SERVER_KEY + - FCM_SERVER_TO + - TWILIO_ACCOUNT_SID + - TWILIO_AUTH_TOKEN + - TWILIO_TO + - TWILIO_FROM + - TELNYX_API_KEY + - TELNYX_PUBLIC_KEY + - APNS_AUTHKEY_8KVVCLA3HL + - APNS_AUTH_ID + - APNS_TEAM_ID + - APNS_BUNDLE_ID + - APNS_TO + - MSG_91_SENDER_ID + - MSG_91_AUTH_KEY + - MSG_91_TO + - MSG_91_FROM + - TEST_EMAIL + - TEST_FROM_EMAIL + - VONAGE_API_KEY + - VONAGE_API_SECRET + - VONAGE_TO + - VONAGE_FROM build: context: . volumes: diff --git a/src/Utopia/Messaging/Adapters/Email/Postmark.php b/src/Utopia/Messaging/Adapters/Email/Postmark.php new file mode 100644 index 00000000..59179e68 --- /dev/null +++ b/src/Utopia/Messaging/Adapters/Email/Postmark.php @@ -0,0 +1,67 @@ +isHtml() ? 'HtmlBody' : 'TextBody'; + + $response = $this->request( + method: 'POST', + url: 'https://api.postmarkapp.com/email', + headers: [ + 'Accept: application/json', + 'Content-Type: application/json', + 'X-Postmark-Server-Token: '.$this->apiKey, + ], + body: \json_encode([ + 'To' => \implode(',', $message->getTo()), + 'From' => $message->getFrom(), + 'Subject' => $message->getSubject(), + $bodyKey => $message->getContent(), + ]), + ); + + return $response; + } +} diff --git a/tests/e2e/Email/PostmarkTest.php b/tests/e2e/Email/PostmarkTest.php new file mode 100644 index 00000000..8bbcab76 --- /dev/null +++ b/tests/e2e/Email/PostmarkTest.php @@ -0,0 +1,35 @@ +send($message)); + + $this->assertEquals($to, $result['To']); + $this->assertEquals('OK', $result['Message']); + } +}