Take the proxy from smtp_proxy instead of HTTP_PROXY (#316)

* Take the proxy from SMTP_PROXY instead of HTTP_PROXY

HTTP_PROXY says how to reach the web, and on a self-hosted runner it is
routinely set machine-wide while the mail server has to be reached
directly. Sending SMTP through it makes such a proxy refuse the
connection, and there was no way to opt out.

Read the protocol-specific SMTP_PROXY instead, and honour NO_PROXY so a
host can be exempted from it.

Co-Authored-By: Claude (Opus 5) <noreply@anthropic.com>

* Accept smtps_proxy too, and prefer the lowercase spelling

curl reads the lowercase name first and falls back to the uppercase one,
and an implicit TLS connection is configured through smtps_proxy rather
than smtp_proxy.

Co-Authored-By: Claude (Opus 5) <noreply@anthropic.com>

---------

Co-authored-by: Claude (Opus 5) <noreply@anthropic.com>
This commit is contained in:
silverwind
2026-09-08 16:47:01 +02:00
committed by GitHub
parent 8043a5ab22
commit ca8dbb4d4f
2 changed files with 19 additions and 3 deletions
+2 -2
View File
@@ -16,8 +16,8 @@ Some features:
- name: Send mail - name: Send mail
uses: dawidd6/action-send-mail@<REF> uses: dawidd6/action-send-mail@<REF>
env: env:
# Optional http proxy: # Optional proxy, NO_PROXY is honored too:
HTTP_PROXY: http://proxy.example.test:3128 SMTP_PROXY: http://proxy.example.test:3128
with: with:
# Specify connection via URL (replaces server_address, server_port, secure, # Specify connection via URL (replaces server_address, server_port, secure,
# username and password) # username and password)
+17 -1
View File
@@ -6,6 +6,22 @@ import fs from "node:fs";
import showdown from "showdown"; import showdown from "showdown";
import path from "node:path"; import path from "node:path";
// smtp_proxy or smtps_proxy, exempted by no_proxy, each preferred lowercase like curl.
function getProxy(host) {
const env = (name) => process.env[name] || process.env[name.toUpperCase()];
const proxy = env("smtp_proxy") || env("smtps_proxy");
if (!proxy) return undefined;
host = `.${host.toLowerCase()}`;
const excluded = (env("no_proxy") || "")
.split(",")
.map((entry) => entry.trim().replace(/^\./, "").toLowerCase())
.some((entry) => entry && (entry === "*" || host.endsWith(`.${entry}`)));
return excluded ? undefined : proxy;
}
function getText(textOrFile, convertMarkdown) { function getText(textOrFile, convertMarkdown) {
let text = textOrFile; let text = textOrFile;
@@ -188,7 +204,7 @@ async function main() {
: undefined, : undefined,
logger: nodemailerdebug == "true" ? true : nodemailerlog, logger: nodemailerdebug == "true" ? true : nodemailerlog,
debug: nodemailerdebug, debug: nodemailerdebug,
proxy: process.env.HTTP_PROXY, proxy: getProxy(serverAddress),
}); });
const messageOptions = { const messageOptions = {