### Node.js Express Server Setup with Postmark Source: https://postmarkapp.com/developer/integration/ai-prompts Install necessary packages and initialize an Express server with the Postmark client. Ensure your Postmark Server API token is set in your environment variables. ```bash npm install postmark dotenv express ``` ```javascript import express from 'express'; import { ServerClient } from 'postmark'; import dotenv from 'dotenv'; dotenv.config(); const app = express(); app.use(express.json()); // Initialize Postmark client const client = new ServerClient(process.env.POSTMARK_SERVER_TOKEN); ``` -------------------------------- ### Install Dependencies Source: https://postmarkapp.com/developer/integration/ai-prompts Install the necessary libraries for Better Auth and Postmark integration. ```bash npm install better-auth postmark ``` -------------------------------- ### Install Postmark Python SDK Source: https://postmarkapp.com/developer/integration/official-libraries Install the postmark-python library from PyPI. This SDK is fully asynchronous. ```bash pip install postmark-python ``` -------------------------------- ### Install Postmark CLI Source: https://postmarkapp.com/developer/integration/official-libraries Install the Postmark Command Line Interface globally using npm. ```bash npm i postmark-cli -g ``` -------------------------------- ### Install Postmark Node.js Package with npm Source: https://postmarkapp.com/developer/integration/official-libraries Install the Postmark Node.js library using npm. ```bash npm install postmark --save ``` -------------------------------- ### Install Postmark PHP Library with Composer Source: https://postmarkapp.com/developer/integration/official-libraries Install the Postmark PHP library using Composer. ```bash composer require wildbit/postmark-php ``` -------------------------------- ### Example Server Response Source: https://postmarkapp.com/developer/api/servers-api This is an example JSON response when successfully retrieving server details. ```json HTTP/1.1 200 OK Content-Type: application/json { "ID": 1, "Name": "Staging Testing", "ApiTokens": [ "server token" ], "Color": "red", "SmtpApiActivated": true, "RawEmailEnabled": false, "DeliveryType": "Live", "ServerLink": "https://postmarkapp.com/servers/1/streams", "InboundAddress": "yourhash@inbound.postmarkapp.com", "InboundHookUrl": "https://hooks.example.com/inbound", "BounceHookUrl": "https://hooks.example.com/bounce", "OpenHookUrl": "https://hooks.example.com/open", "DeliveryHookUrl": "https://hooks.example.com/delivery", "PostFirstOpenOnly": false, "InboundDomain": "", "InboundHash": "yourhash", "InboundSpamThreshold": 0, "TrackOpens": false, "TrackLinks": "None", "IncludeBounceContentInHook": true, "ClickHookUrl": "https://hooks.example.com/click", "EnableSmtpApiErrorHooks": false } ``` -------------------------------- ### Example Response for Message Opens Source: https://postmarkapp.com/developer/api/messages-api This is an example of a successful response when retrieving message opens. ```json { "TotalCount": 1, "Opens": [ { "RecordType": "Open", "Client": { "Name": "Chrome 34.0.1847.131", "Company": "Google Inc.", "Family": "Chrome" }, "OS": { "Name": "OS X 10.7 Lion", "Company": "Apple Computer, Inc.", "Family": "OS X" }, "Platform": "WebMail", "UserAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.131 Safari/537.36", "Geo": { "CountryISOCode": "RS", "Country": "Serbia", "RegionISOCode": "VO", "Region": "Autonomna Pokrajina Vojvodina", "City": "Novi Sad", "Zip": "21000", "Coords": "45.2517,19.8369", "IP": "188.2.95.4" }, "MessageID": "927e56d4-dc66-4070-bbf0-1db76c2ae14b", "MessageStream": "outbound", "ReceivedAt": "2014-04-30T05:04:23.8768746-04:00", "Tag": "welcome-user", "Recipient": "john.doe@yahoo.com" } ] } ``` -------------------------------- ### AI Prompt for Better Auth and Postmark Integration Source: https://postmarkapp.com/developer/integration/ai-prompts This prompt guides an AI in setting up Postmark with Better Auth for authentication emails. It covers package installation, configuration, email verification, password reset flows, email template design, client-side integration, and best practices, specifying a Next.js with TypeScript environment. ```markdown Integrate Postmark with Better Auth for authentication emails. Include: 1. Better Auth setup with Postmark: - Install required packages (better-auth, postmark) - Configure Better Auth with email and password authentication - Set up Postmark as the email provider - Configure environment variables 2. Email verification flow: - Implement sendVerificationEmail function using Postmark - Send verification emails on signup - Handle email verification callback - Optionally auto sign-in after verification - Create verification email template with clear CTA 3. Password reset flow: - Implement sendResetPassword function using Postmark - Trigger password reset from client - Send secure password reset emails via Postmark - Create password reset email template - Handle reset token validation 4. Email templates: - Design mobile-responsive email verification template - Design password reset template - Include security messaging - Use Better Auth's provided URL and token - Brand emails with your company identity 5. Client-side integration: - Set up Better Auth client - Handle signup with email verification - Trigger password reset flow - Handle verification callbacks - Display appropriate user feedback 6. Best practices: - Use environment variables for API tokens - Implement proper error handling - Add rate limiting for email sends - Log authentication events - Test email delivery in development Use Next.js with TypeScript. Show both server-side Better Auth config and client-side React components. ``` -------------------------------- ### Install Postmark Ruby Gem Source: https://postmarkapp.com/developer/integration/official-libraries Install the Postmark Ruby gem using Bundler. Run bundle install after adding it to your Gemfile. ```ruby gem 'postmark' ``` -------------------------------- ### Install Postmark .NET NuGet Package Source: https://postmarkapp.com/developer/integration/official-libraries Install the Postmark.NET NuGet package for easy API integration in .NET projects. ```nuget PM> Install-Package Postmark ``` -------------------------------- ### Example Response for Get Template Source: https://postmarkapp.com/developer/api/templates-api This JSON object represents a successfully retrieved template, including its ID, name, content, and associated server information. ```json { "Name": "Onboarding Email", "TemplateId": 1234, "Subject": "Hi there, {{Name}}", "HtmlBody": "Hello dear Postmark user. {{Name}}", "TextBody": "{{Name}} is a {{Occupation}}", "AssociatedServerId": 1, "Active": false, "Alias": "onboarding-v1", "TemplateType": "Standard", "LayoutTemplate": "my-layout" } ``` ```json { "Name": "Receipt Email", "TemplateId": 1235, "Subject": "Receipt for {{ product_name }}", "HtmlBody": "
This is a receipt for {{ product_name }}...", "TextBody": "This is a receipt for {{ product_name }}", "AssociatedServerId": 1, "Active": false, "Alias": "receipt-v1", "TemplateType": "Standard", "LayoutTemplate": "null" } ``` -------------------------------- ### Install Grunt Postmark Plugin Source: https://postmarkapp.com/developer/integration/official-libraries Install the Grunt Postmark plugin as an npm package. ```bash npm install grunt-postmark --save ``` -------------------------------- ### Example Server Response Source: https://postmarkapp.com/developer/api/servers-api This is an example of a successful response when retrieving server details. It includes various configuration options for a Postmark server. ```json HTTP/1.1 200 OK Content-Type: application/json { "ID": 1, "Name": "Staging Testing", "ApiTokens": [ "server token" ], "Color": "red", "SmtpApiActivated": true, "RawEmailEnabled": false, "DeliveryType": "Live", "ServerLink": "https://postmarkapp.com/servers/1/streams", "InboundAddress": "yourhash@inbound.postmarkapp.com", "InboundHookUrl": "https://hooks.example.com/inbound", "BounceHookUrl": "https://hooks.example.com/bounce", "OpenHookUrl": "https://hooks.example.com/open", "DeliveryHookUrl": "https://hooks.example.com/delivery", "PostFirstOpenOnly": false, "InboundDomain": "", "InboundHash": "yourhash", "InboundSpamThreshold": 5, "TrackOpens": false, "TrackLinks": "None", "IncludeBounceContentInHook": true, "ClickHookUrl": "https://hooks.example.com/click", "EnableSmtpApiErrorHooks": false } ``` -------------------------------- ### Install Postmark Craft Plugin with Composer Source: https://postmarkapp.com/developer/integration/official-libraries Install the Postmark Craft plugin using Composer. ```bash composer require craftcms/postmark ``` -------------------------------- ### Example Webhook Response Source: https://postmarkapp.com/developer/api/webhooks-api This is an example of a successful response when retrieving webhook details. ```json HTTP/1.1 200 OK Content-Type: application/json { "ID": 1234567, "Url": "https://www.example.com/webhooks", "MessageStream": "outbound", "HttpAuth":{ "Username": "user", "Password": "pass" }, "HttpHeaders":[ { "Name": "name", "Value": "value" } ], "Triggers": { "Open":{ "Enabled": true, "PostFirstOpenOnly": false }, "Click":{ "Enabled": true }, "Delivery":{ "Enabled": true }, "Bounce":{ "Enabled": true, "IncludeContent": false }, "SpamComplaint":{ "Enabled": true, "IncludeContent": false }, "SubscriptionChange": { "Enabled": false } } } ``` -------------------------------- ### Install Postmark Driver for Laravel Source: https://postmarkapp.com/developer/integration/ai-prompts Use Composer to install the official Postmark driver for Laravel. This is the first step in integrating Postmark. ```bash # Install Postmark driver composer require wildbit/laravel-postmark ``` -------------------------------- ### Server API Example Response Source: https://postmarkapp.com/developer/api/server-api This snippet shows an example of a successful response from the Server API, detailing the structure and fields returned for a server configuration. ```APIDOC ## GET /servers/{ID} ### Description Retrieves the details of a specific server configuration. ### Method GET ### Endpoint /servers/{ID} ### Parameters #### Path Parameters - **ID** (integer) - Required - The unique identifier of the server. ### Response #### Success Response (200) - **ID** (integer) - The unique identifier of the server. - **Name** (string) - The name of the server. - **ApiTokens** (array of strings) - A list of API tokens associated with the server. - **Color** (string) - The color associated with the server. - **SmtpApiActivated** (boolean) - Indicates if SMTP API is activated. - **RawEmailEnabled** (boolean) - Indicates if raw email is enabled. - **DeliveryType** (string) - The type of delivery for the server. - **ServerLink** (string) - A link to the server details page. - **InboundAddress** (string) - The inbound email address for the server. - **InboundHookUrl** (string) - The URL for inbound email webhooks. - **BounceHookUrl** (string) - The URL for bounce webhooks. - **OpenHookUrl** (string) - The URL for open tracking webhooks. - **DeliveryHookUrl** (string) - The URL for delivery status webhooks. - **PostFirstOpenOnly** (boolean) - Whether to only post the first open event. - **InboundDomain** (string) - The inbound domain for the server. - **InboundHash** (string) - The inbound hash for the server. - **InboundSpamThreshold** (integer) - The spam threshold for inbound emails. - **TrackOpens** (boolean) - Indicates if opens are tracked. - **TrackOpens** (string) - The tracking opens setting. - **IncludeBounceContentInHook** (boolean) - Whether to include bounce content in webhooks. - **ClickHookUrl** (string) - The URL for click tracking webhooks. - **EnableSmtpApiErrorHooks** (boolean) - Indicates if SMTP API error webhooks are enabled. #### Response Example { "ID": 1, "Name": "Production Testing", "ApiTokens": [ "Server Token" ], "Color": "blue", "SmtpApiActivated": false, "RawEmailEnabled": false, "DeliveryType": "Live", "ServerLink": "https://postmarkapp.com/servers/1/streams", "InboundAddress": "yourhash@inbound.postmarkapp.com", "InboundHookUrl": "https://hooks.example.com/inbound", "BounceHookUrl": "https://hooks.example.com/bounce", "OpenHookUrl": "https://hooks.example.com/open", "DeliveryHookUrl": "https://hooks.example.com/delivery", "PostFirstOpenOnly": false, "InboundDomain": "", "InboundHash": "yourhash", "InboundSpamThreshold": 10, "TrackOpens": false, "TrackOpens": "None", "IncludeBounceContentInHook": true, "ClickHookUrl": "https://hooks.example.com/click", "EnableSmtpApiErrorHooks": true } ``` -------------------------------- ### Install Postmark Plugin in Craft CMS Source: https://postmarkapp.com/developer/integration/official-libraries Tell Craft CMS to install the Postmark plugin after it has been added via Composer. ```bash ./craft install/plugin postmark ``` -------------------------------- ### Get Bulk Email Request Status - Response Example Source: https://postmarkapp.com/developer/api/bulk-email This is an example of a successful response when querying the status of a bulk email request. ```json HTTP/1.1 200 OK Content-Type: application/json { "Id": "dc5e5d98-c073-4c97-8ee5-f897dfd28b47", "SubmittedAt": "2024-07-22T15:39:49.3723691Z", "TotalMessages": 1, "PercentageCompleted": 1, "Status": "Completed", "Subject": "Hello" } ``` -------------------------------- ### Example Response for Outbound Clicks Source: https://postmarkapp.com/developer/api/stats-api This is an example JSON response for a request to get outbound click counts. It shows clicks aggregated by date and overall. ```json HTTP/1.1 200 OK Content-Type: application/json { "Days": [ { "Date": "2014-01-01", "Apple Mail": 1, "Outlook 2010": 1 }, { "Date": "2014-01-02", "Apple Mail": 1, "Outlook 2010": 2 }, { "Date": "2014-01-04", "Apple Mail": 4, "Outlook 2010": 5 } ], "Apple Mail": 6, "Outlook 2010": 8 } ``` -------------------------------- ### Postmark CLI Usage Example Source: https://postmarkapp.com/developer/integration/official-libraries View available commands and options for the Postmark CLI. ```bash $ postmark Commands: postmark email