From ba302ba66e88942841281c984a6b31ca6d6289e6 Mon Sep 17 00:00:00 2001 From: Spiros Kalogeropoulos <37223501+KaSpiros@users.noreply.github.com> Date: Fri, 27 Feb 2026 12:38:27 +0000 Subject: [PATCH] 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 --- .github/workflows/test.yml | 1 + README.md | 2 ++ action.yml | 3 +++ main.js | 2 ++ 4 files changed, 8 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c1cf2b81..017ff877 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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: | diff --git a/README.md b/README.md index b490e95d..a8b2f660 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/action.yml b/action.yml index 51172389..30945651 100644 --- a/action.yml +++ b/action.yml @@ -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 diff --git a/main.js b/main.js index 6a557333..976dd939 100644 --- a/main.js +++ b/main.js @@ -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,