diff --git a/CHANGELOG.md b/CHANGELOG.md index d1b8a75..943134c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # CHANGELOG +**v0.1.0-alpha.3:** +- `README.md`: notice about test mode +- Support for test mode logging + **v0.1.0-alpha.2:** - `README.md` cleanup (listing of components) - `Image` component now requires only `src`; the other params are optional diff --git a/README.md b/README.md index 75e9e42..21e3e88 100644 --- a/README.md +++ b/README.md @@ -100,6 +100,18 @@ There are more examples in the [examples](examples) folder ✨ > [!NOTE] > 🚧 **The SDK is not stable yet.** This API might change as more features are added. Please watch the repo for the changes in the [CHANGELOG](CHANGELOG.md). +## 🏗 Debugging + +You can generate _test API keys_ by activating the **Test Mode** in your dashboard. By using these keys, you'll be able to view your fully rendered emails without actually sending them. + +When you use a test API key in your SDK, the following output will appear in your logs when you try to send an email: + +```log +Templateless [TEST MODE]: Emailed user@example.com, preview: https://tmpl.sh/ATMxHLX4r9aE +``` + +The preview link will display the email, but you must be logged in to Templateless to view it. + ## 🔳 Components Emails are crafted programmatically by making function calls. There's no dealing with HTML or drag-and-drop builders. @@ -251,7 +263,7 @@ If you'd like your recipients to be able to read the email in a browser, you can You can optionally provide the text for the link. If none is provided, default is used: "View in browser" -**This will make the email public to anyone that has access to the link.** +**Anyone who knows the link will be able to see the email.** ```php Content::builder() diff --git a/src/Templateless.php b/src/Templateless.php index 7f2a9e9..f68b864 100644 --- a/src/Templateless.php +++ b/src/Templateless.php @@ -82,6 +82,13 @@ public function sendMany($emails) } elseif ($statusCode === 200) { $responseText = $response->getBody()->getContents(); $emailResponse = json_decode($responseText, true); + + if (!empty($emailResponse['previews'])) { + foreach ($emailResponse['previews'] as $preview) { + echo "Templateless [TEST MODE]: Emailed {$preview['email']}, preview: https://tmpl.sh/{$preview['preview']}\n"; + } + } + if ($emailResponse !== null && isset($emailResponse['emails'])) { return new EmailResponse($emailResponse['emails']); } else {