Add support for custom email headers via JSON input (#264)

* Adding custom header with JSON support

* Adding headers in test workflow

---------

Co-authored-by: W506810_wexinc <spiros.kalogeropoulos@wexinc.com>
This commit is contained in:
Spiros Kalogeropoulos
2026-02-27 12:38:27 +00:00
committed by GitHub
parent 7c60f8f904
commit ba302ba66e
4 changed files with 8 additions and 0 deletions

View File

@@ -46,6 +46,7 @@ jobs:
convert_markdown: true
attachments: package.json,action.yml
priority: high
headers: '{"X-My-Test-Header": "Passed"}'
- name: Get mail
run: |

View File

@@ -63,6 +63,8 @@ Some features:
attachments: attachments.zip,git.diff,./dist/static/*.js
# Optional priority: 'high', 'normal' (default) or 'low'
priority: low
# Optional custom headers:
headers: '{"X-Priority": "3 (Normal)", "X-My-Header": "MyValue"}'
# Optional nodemailerlog: true/false
nodemailerlog: false
# Optional nodemailerdebug: true/false if true lognodem will also be set true

View File

@@ -57,6 +57,9 @@ inputs:
priority:
description: Set Priority level for the mail message to 'high', 'normal' (default) or 'low'
required: false
headers:
description: 'Custom headers for the mail message as a JSON string (e.g., {"X-Custom-Header": "value"})'
required: false
nodemailerlog:
description: Log option for nodemailer
required: false

View File

@@ -115,6 +115,7 @@ async function main() {
required: false,
});
const envelopeTo = core.getInput("envelope_to", { required: false });
const headers = core.getInput("headers", { required: false });
// if neither to, cc or bcc is provided, throw error
if (!to && !cc && !bcc) {
@@ -166,6 +167,7 @@ async function main() {
? getText(htmlBody, convertMarkdown)
: undefined,
priority: priority ? priority : undefined,
headers: headers ? JSON.parse(headers) : undefined,
attachments: attachments
? await getAttachments(attachments)
: undefined,