A GitHub Action to send emails using the Postmark API with support for HTML templates.
This action allows you to send emails through Postmark's API directly from your GitHub Actions workflow. It supports both plain text and HTML emails, with the ability to use template files and dynamic template variables.
- Send plain text or HTML emails
- Support for HTML template files
- Dynamic template variable substitution
- Simple integration with GitHub Actions workflows
- A Postmark account and API token (sign up at postmarkapp.com)
- Node.js 22 (handled automatically by GitHub Actions)
- Sender email address must be verified with Postmark
steps:
- name: Send Email
uses: ashwinkhode/postmark-action@v1
with:
postmark-token: ${{ secrets.POSTMARK_TOKEN }}
to: '[email protected]'
from: '[email protected]'
subject: 'Test Email'
body: 'This is a test email sent from GitHub Actions!'
is-html: 'false'
steps:
- name: Send HTML Email
uses: ashwinkhode/postmark-action@v1
with:
postmark-token: ${{ secrets.POSTMARK_TOKEN }}
to: '[email protected]'
from: '[email protected]'
subject: 'HTML Test Email'
body: '<h1>Hello!</h1><p>This is an HTML email.</p>'
is-html: 'true'
steps:
- name: Send Templated Email
uses: ashwinkhode/postmark-action@v1
with:
postmark-token: ${{ secrets.POSTMARK_TOKEN }}
to: '[email protected]'
from: '[email protected]'
subject: 'Templated Email'
template-path: './email-templates/welcome.html'
template-data: '{"name": "John", "company": "Acme Inc"}'
is-html: 'true'
Input | Description | Required | Default |
---|---|---|---|
postmark-token |
Your Postmark API token | Yes | - |
to |
Recipient email address | Yes | - |
from |
Sender email address | Yes | - |
subject |
Email subject | Yes | - |
body |
Email body content | No* | - |
template-path |
Path to the HTML template file | No | - |
template-data |
JSON string containing template variables | No | - |
is-html |
Whether the body content is HTML | Yes | - |
* body
is required unless using a template
[Rest of the README remains the same...]
Output | Description |
---|---|
status |
Status of the email sending operation |
When using a template file, you can pass variables using the template-data
input. The variables can come from multiple sources:
template-data: '{"username": "John", "resetLink": "https://example.com/reset"}'
You can use any GitHub Actions context variables in your template data:
steps:
- name: Send Workflow Notification
uses: ashwinkhode/postmark-action@v1
with:
# ... other inputs ...
template-data: |
{
"repository": "${{ github.repository }}",
"workflow": "${{ github.workflow }}",
"actor": "${{ github.actor }}",
"commit": "${{ github.sha }}",
"ref": "${{ github.ref }}",
"event": "${{ github.event_name }}"
}
env:
DEPLOY_ENV: production
VERSION: 1.0.0
steps:
- name: Send Deploy Notification
uses: ashwinkhode/postmark-action@v1
with:
# ... other inputs ...
template-data: |
{
"environment": "${{ env.DEPLOY_ENV }}",
"version": "${{ env.VERSION }}"
}
steps:
- name: Get Test Results
id: tests
run: |
echo "::set-output name=passed::42"
echo "::set-output name=failed::3"
- name: Send Test Report
uses: ashwinkhode/postmark-action@v1
with:
# ... other inputs ...
template-data: |
{
"testsPassed": "${{ steps.tests.outputs.passed }}",
"testsFailed": "${{ steps.tests.outputs.failed }}"
}
In your template file, use double curly braces to reference variables:
<h1>Workflow Report</h1>
<p>Repository: {{repository}}</p>
<p>Triggered by: {{actor}}</p>
<p>Environment: {{environment}}</p>
<p>Test Results:</p>
<ul>
<li>Passed: {{testsPassed}}</li>
<li>Failed: {{testsFailed}}</li>
</ul>
You can also use GitHub context variables in the subject line:
subject: 'Build ${{ github.run_number }} - ${{ job.status }} on ${{ github.repository }}'
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature
) - Commit your changes (
git commit -m 'Add some AmazingFeature'
) - Push to the branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Ashwin Khode (@ashwin4real)
- For issues with this Action: Open an issue
- For API questions: Postmark's API Documentation
This project uses:
This project is licensed under the MIT License - see the LICENSE file for details.
This GitHub Action is an independent, unofficial integration and is not affiliated with, endorsed by, or connected to Postmark® or Wildbit LLC. Postmark® is a registered trademark of Wildbit LLC.
This Action uses Postmark's public API. For official resources:
The MIT License applies only to the code in this repository and not to Postmark's services or API. Users must comply with Postmark's Terms of Service and Sender Policy.
Note: This Action is maintained independently. For official Postmark integrations, visit postmarkapp.com.