Postmark -> Send Single Email
Action summary
Postmark -> Send Single Email
Postmark → Send Single Email
Overview
This function allows you to send a single email using the Postmark API. It requires parameters such as the sender email address, recipient email address, subject, body (in either HTML or plain text format), 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.
- from_email (text) Required
- Description: The email address of the sender.
- Example:
noreply@yourdomain.com
- to_email (text) Required
- Description: The email address of the recipient.
- Example:
user@example.com
- subject (text) Required
- Description: The subject line of the email.
- Example:
Welcome to Our Service
- html_body (text) Optional
- Description: The HTML content of the email message. If provided, it takes precedence over
text_body
. - Example:
<h1>Hello, John!</h1><p>Thank you for signing up.</p>
- 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. - Example:
Hello, John! Thank you for signing up.
- Description: The plain text content of the email message. If provided and
Function Stack
1. Create Variable
- Create Variable:
api_url
- Purpose: Constructs the API URL for sending single emails.
2. Create Variable
- Create Variable:
api_token
- Purpose: Stores the Postmark API token.
3. Precondition Logic
- 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.- Purpose: Ensures recipient email address is formatted correctly.
- Precondition:
to_email
should not exceed 50 email addresses.- Purpose: Limits the number of recipients to avoid batch size issues.
- Precondition: Either
text_body
orhtml_body
(or both) are provided.- Purpose: Ensures that at least one form of email content is available.
- Precondition:
html_body
is a valid HTML format.- Purpose: Ensures that if HTML is provided, it is well-formed.
4. API Request
- API Request to:
https://api.postmarkapp.com/email
- Purpose: Sends a POST request to the
api_url
with the following payload:
- Purpose: Sends a POST request to the
{
"from_email": "noreply@yourdomain.com",
"to_email": "user@example.com",
"subject": "Welcome to Our Service",
"html_body": "<h1>Hello, John!</h1><p>Thank you for signing up.</p>", // Optional
"text_body": "Hello, John! Thank you for signing up." // Optional
}
5. Create Variable
- Create Variable:
postmark_response
- Purpose: Stores the response from the Postmark API.
6. Create Variable
- Create Variable:
response
- Purpose: Creates a response object containing the result from the Postmark API.
7. Conditional Check
- Conditional: Checks if the response status is 200 and the error code is 0.
- If True: Updates the
response
object to indicate success. - If False: Updates the
response
object to indicate an error.
- If True: Updates the
Response
The function returns either a success message or an error message depending on the outcome.
Success Response
{
"To": "user@example.com",
"SubmittedAt": "2024-10-07T14:33:15.817Z",
"MessageID": "message-id-1",
"ErrorCode": 0,
"Message": "OK"
}
Error Response
{
"ErrorCode": 401,
"Message": "Unauthorized: Missing or incorrect API key."
}
Example
Input
{
"from_email": "noreply@yourdomain.com",
"to_email": "user@example.com",
"subject": "Welcome to Our Service",
"html_body": "<h1>Hello, John!</h1><p>Thank you for signing up.</p>",
"text_body": "Hello, John! Thank you for signing up."
}
Output
{
"To": "user@example.com",
"SubmittedAt": "2024-10-07T14:33:15.817Z",
"MessageID": "message-id-1",
"ErrorCode": 0,
"Message": "OK"
}
Version notes
2024-10-09 17:57:27
Current
Postmark → Send Single Email
Overview
This function allows you to send a single email using the Postmark API. It requires parameters such as the sender email address, recipient email address, subject, body (in either HTML or plain text format), 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.
- from_email (text) Required
- Description: The email address of the sender.
- Example:
noreply@yourdomain.com
- to_email (text) Required
- Description: The email address of the recipient.
- Example:
user@example.com
- subject (text) Required
- Description: The subject line of the email.
- Example:
Welcome to Our Service
- html_body (text) Optional
- Description: The HTML content of the email message. If provided, it takes precedence over
text_body
. - Example:
<html><body><strong>Hello</strong> dear Postmark user.</body></html>
- 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. - Example:
Hello, John! Thank you for signing up.
- Description: The plain text content of the email message. If provided and
Function Stack
1. Create Variable
- Create Variable:
api_url
- Purpose: Constructs the API URL for sending single emails.
2. Create Variable
- Create Variable:
api_token
- Purpose: Stores the Postmark API token.
3. Precondition Logic
- 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.- Purpose: Ensures recipient email address is formatted correctly.
- Precondition:
to_email
should not exceed 50 email addresses.- Purpose: Limits the number of recipients to avoid batch size issues.
- Precondition: Either
text_body
orhtml_body
(or both) are provided.- Purpose: Ensures that at least one form of email content is available.
- Precondition:
html_body
is a valid HTML format.- Purpose: Ensures that if HTML is provided, it is well-formed.
4. API Request
- API Request to:
https://api.postmarkapp.com/email
- Purpose: Sends a POST request to the
api_url
with the following payload:
- Purpose: Sends a POST request to the
{
"from_email": "noreply@yourdomain.com",
"to_email": "user@example.com",
"subject": "Welcome to Our Service",
"html_body": "<html><body><strong>Hello</strong> dear Postmark user.</body></html>", // Optional
"text_body": "Hello, John! Thank you for signing up." // Optional
}
5. Create Variable
- Create Variable:
postmark_response
- Purpose: Stores the response from the Postmark API.
6. Create Variable
- Create Variable:
response
- Purpose: Creates a response object containing the result from the Postmark API.
7. Conditional Check
- Conditional: Checks if the response status is 200 and the error code is 0.
- If True: Updates the
response
object to indicate success. - If False: Updates the
response
object to indicate an error.
- If True: Updates the
Response
The function returns either a success message or an error message depending on the outcome.
Success Response
{
"To": "user@example.com",
"SubmittedAt": "2024-10-07T14:33:15.817Z",
"MessageID": "message-id-1",
"ErrorCode": 0,
"Message": "OK"
}
Error Response
{
"ErrorCode": 401,
"Message": "Unauthorized: Missing or incorrect API key."
}
Example
Input
{
"from_email": "noreply@yourdomain.com",
"to_email": "user@example.com",
"subject": "Welcome to Our Service",
"html_body": "<html><body><strong>Hello</strong> dear Postmark user.</body></html>",
"text_body": "Hello, John! Thank you for signing up."
}
Output
{
"To": "user@example.com",
"SubmittedAt": "2024-10-07T14:33:15.817Z",
"MessageID": "message-id-1",
"ErrorCode": 0,
"Message": "OK"
}