Postmark -> Send Batch Emails
Action summary
Postmark -> Send Batch Emails
Postmark → Send Batch Emails
Overview
This function allows you to send a batch of emails using the Postmark API. It requires parameters such as the sender email address, recipient email addresses, subject, body, and optionally a template ID.
Inputs
- postmark_base_url (registry|text) Required
- Description: The base url for calling the Postmark API (e.g., "https://api.postmarkapp.com/").
- postmark_server_token (registry|text) Required Sensitive data
- Description: This is the Postmark Server API Token (e.g., "14g8dce4-7054-47c9-a18a-2107e5cf4e41"). This is needed for authentication on endpoints.
- message (Object[]) Required
Description: An Object of message, each containing the following properties:
- from_email (text) Required
- Description: The email address of the sender.
- to_email (text) Required
- Description: The email address of the recipient.
- subject (text) Required
- Description: The subject line of the email.
- html_body (text) Optional
- Description: The HTML content of the email message. If provided, it takes precedence over
text_body
.
- Description: The HTML content of the email message. If provided, it takes precedence over
- text_body (text) Optional
- Description: The plain text content of the email message. If provided and
html_body
is not, it will be used.
- Description: The plain text content of the email message. If provided and
- from_email (text) Required
Function Stack
1. Create Variable: api_url
- Purpose: Constructs the API URL for sending batch emails.
2. Create Variable: api_token
- Purpose: Stores the Postmark API token.
3. Create Variable: messages_payload
- Purpose: Initializes an empty array to store the Postmark formatted messages.
4. Precondition
- Precondition:
from_email
should not exceed 255 characters.- Purpose: Ensures the sender email address is not too long.
- Precondition:
from_email
is a valid email format.- Purpose: Ensures the sender email address is formatted correctly.
- Precondition:
to_email
is a valid email format and allows comma-separated values.- Purpose: Ensures recipient email addresses are formatted correctly and the list is not too long.
- Precondition:
to_email
should not exceed 50 email addresses.- Purpose: Limits the number of recipients per batch.
- Precondition:
text_body
orhtml_body
!= null- Purpose: Either
text_body
orhtml_body
(or both) are provided.
- Purpose: Either
- Precondition:
html_body
is a valid HTML format- Purpose:
html_body
is a valid HTML format
- Purpose:
- Convert Message: Postmark Format
- Purpose: Create a Postmark message object with the required fields, ensuring that
to_email
is converted to an array if it's a comma-separated list.
- Purpose: Create a Postmark message object with the required fields, ensuring that
- Update Variable: Increment
message_counter
.- Purpose: Update
message_counter
.
- Purpose: Update
5. API Request
- Sends a POST request to the
api_url
with themessages_payload
as the request body.
6. Create Variable: postmark_response
- Purpose: Stores the response from the Postmark API.
7 Create Variable: response
- Purpose: Creates a response object with the result from the Postmark API.
Response
The function returns a success message or an error message depending on the outcome.
Success Response
{
"To": "user1@example.com",
"SubmittedAt": "2024-10-07T14:33:15.817Z",
"MessageID": "message-id-1",
"ErrorCode": 0,
"Message": "OK"
},
{
"To": "user2@example.com",
"SubmittedAt": "2024-10-07T14:33:15.817Z",
"MessageID": "message-id-2",
"ErrorCode": 0,
"Message": "OK"
}
Error Response
{
"ErrorCode": 401,
"Message": "Unauthorized: Missing or incorrect API key."
}
Example
Input
{
"message": [
{
"from_email": "sender@example.com",
"to_email": "recipient1@example.com,recipient2@example.com",
"subject": "Welcome to Our Service",
"html_body": "<h1>Welcome!</h1><p>Thank you for joining our service.</p>",
"text_body": "Welcome! Thank you for joining our service."
},
{
"from_email": "admin@example.com",
"to_email": "recipient3@example.com",
"subject": "Important Update",
"html_body": "<h1>Update</h1><p>Here’s an important update for you.</p>"
}
]
}
Output
[
{
"To": "recipient1@example.com",
"SubmittedAt": "2024-10-07T14:33:15.817Z",
"MessageID": "message-id-1",
"ErrorCode": 0,
"Message": "OK"
},
{
"To": "recipient2@example.com",
"SubmittedAt": "2024-10-07T14:33:15.817Z",
"MessageID": "message-id-2",
"ErrorCode": 0,
"Message": "OK"
},
{
"To": "recipient3@example.com",
"SubmittedAt": "2024-10-07T14:33:15.817Z",
"MessageID": "message-id-3",
"ErrorCode": 0,
"Message": "OK"
}
]
Version notes
2024-10-09 18:03:53
Current
Postmark → Send Batch Emails
Overview
This function allows you to send a batch of emails using the Postmark API. It requires parameters such as the sender email address, recipient email addresses, subject, body, and optionally a template ID.
Inputs
- postmark_base_url (registry|text) Required
- Description: The base url for calling the Postmark API (e.g., "https://api.postmarkapp.com/").
- postmark_server_token (registry|text) Required Sensitive data
- Description: This is the Postmark Server API Token (e.g., "14g8dce4-7054-47c9-a18a-2107e5cf4e41"). This is needed for authentication on endpoints.
- message (Object[]) Required
Description: An Object of message, each containing the following properties:
- from_email (text) Required
- Description: The email address of the sender.
- to_email (text) Required
- Description: The email address of the recipient.
- subject (text) Required
- Description: The subject line of the email.
- html_body (text) Optional
- Description: The HTML content of the email message. If provided, it takes precedence over
text_body
.
- Description: The HTML content of the email message. If provided, it takes precedence over
- text_body (text) Optional
- Description: The plain text content of the email message. If provided and
html_body
is not, it will be used.
- Description: The plain text content of the email message. If provided and
- from_email (text) Required
Function Stack
1. Create Variable: api_url
- Purpose: Constructs the API URL for sending batch emails.
2. Create Variable: api_token
- Purpose: Stores the Postmark API token.
3. Create Variable: messages_payload
- Purpose: Initializes an empty array to store the Postmark formatted messages.
4. Precondition
- Precondition:
from_email
should not exceed 255 characters.- Purpose: Ensures the sender email address is not too long.
- Precondition:
from_email
is a valid email format.- Purpose: Ensures the sender email address is formatted correctly.
- Precondition:
to_email
is a valid email format and allows comma-separated values.- Purpose: Ensures recipient email addresses are formatted correctly and the list is not too long.
- Precondition:
to_email
should not exceed 50 email addresses.- Purpose: Limits the number of recipients per batch.
- Precondition:
text_body
orhtml_body
!= null- Purpose: Either
text_body
orhtml_body
(or both) are provided.
- Purpose: Either
- Precondition:
html_body
is a valid HTML format- Purpose:
html_body
is a valid HTML format
- Purpose:
- Convert Message: Postmark Format
- Purpose: Create a Postmark message object with the required fields, ensuring that
to_email
is converted to an array if it's a comma-separated list.
- Purpose: Create a Postmark message object with the required fields, ensuring that
- Update Variable: Increment
message_counter
.- Purpose: Update
message_counter
.
- Purpose: Update
5. API Request
- Sends a POST request to the
api_url
with themessages_payload
as the request body.
6. Create Variable: postmark_response
- Purpose: Stores the response from the Postmark API.
7 Create Variable: response
- Purpose: Creates a response object with the result from the Postmark API.
Response
The function returns a success message or an error message depending on the outcome.
Success Response
{
"To": "user1@example.com",
"SubmittedAt": "2024-10-07T14:33:15.817Z",
"MessageID": "message-id-1",
"ErrorCode": 0,
"Message": "OK"
},
{
"To": "user2@example.com",
"SubmittedAt": "2024-10-07T14:33:15.817Z",
"MessageID": "message-id-2",
"ErrorCode": 0,
"Message": "OK"
}
Error Response
{
"ErrorCode": 401,
"Message": "Unauthorized: Missing or incorrect API key."
}
Example
Input
{
"message": [
{
"from_email": "sender@example.com",
"to_email": "recipient1@example.com,recipient2@example.com",
"subject": "Welcome to Our Service",
"html_body": "<html><body><strong>Hello</strong> dear Postmark user.</body></html>",
"text_body": "Welcome! Thank you for joining our service."
},
{
"from_email": "admin@example.com",
"to_email": "recipient3@example.com",
"subject": "Important Update",
"html_body": "<html><body><strong>Hello</strong> dear Postmark user.</body></html>"
}
]
}
Output
[
{
"To": "recipient1@example.com",
"SubmittedAt": "2024-10-07T14:33:15.817Z",
"MessageID": "message-id-1",
"ErrorCode": 0,
"Message": "OK"
},
{
"To": "recipient2@example.com",
"SubmittedAt": "2024-10-07T14:33:15.817Z",
"MessageID": "message-id-2",
"ErrorCode": 0,
"Message": "OK"
},
{
"To": "recipient3@example.com",
"SubmittedAt": "2024-10-07T14:33:15.817Z",
"MessageID": "message-id-3",
"ErrorCode": 0,
"Message": "OK"
}
]