mirror of
https://github.com/dawidd6/action-send-mail.git
synced 2026-09-17 17:09:30 +07:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 03a02a4940 | |||
| ca8dbb4d4f | |||
| 8043a5ab22 |
@@ -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)
|
||||||
@@ -37,6 +37,12 @@ Some features:
|
|||||||
# Optional whether this connection use TLS (default is true if server_port is 465)
|
# Optional whether this connection use TLS (default is true if server_port is 465)
|
||||||
secure: true
|
secure: true
|
||||||
|
|
||||||
|
# Optional: when secure is false (e.g. STARTTLS on port 587), abort the
|
||||||
|
# connection if the server does not support/negotiate STARTTLS, instead
|
||||||
|
# of silently falling back to a plain text connection. Recommended
|
||||||
|
# whenever secure is false and you authenticate with username/password.
|
||||||
|
require_tls: true
|
||||||
|
|
||||||
# Optional (recommended) mail server username:
|
# Optional (recommended) mail server username:
|
||||||
username: ${{secrets.MAIL_USERNAME}}
|
username: ${{secrets.MAIL_USERNAME}}
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,9 @@ inputs:
|
|||||||
default: "25"
|
default: "25"
|
||||||
secure:
|
secure:
|
||||||
description: Whether this connection use TLS (default is true if server_port is 465)
|
description: Whether this connection use TLS (default is true if server_port is 465)
|
||||||
|
require_tls:
|
||||||
|
description: When 'secure' is false, refuse to send if the server does not support STARTTLS (prevents credentials from ever being sent in clear text)
|
||||||
|
required: false
|
||||||
username:
|
username:
|
||||||
description: Authenticate as this user to SMTP server
|
description: Authenticate as this user to SMTP server
|
||||||
password:
|
password:
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|
||||||
@@ -78,6 +94,7 @@ async function main() {
|
|||||||
let serverAddress = core.getInput("server_address");
|
let serverAddress = core.getInput("server_address");
|
||||||
let serverPort = core.getInput("server_port");
|
let serverPort = core.getInput("server_port");
|
||||||
let secure = core.getInput("secure");
|
let secure = core.getInput("secure");
|
||||||
|
const requireTLS = core.getInput("require_tls", { required: false });
|
||||||
let username = core.getInput("username");
|
let username = core.getInput("username");
|
||||||
let password = core.getInput("password");
|
let password = core.getInput("password");
|
||||||
|
|
||||||
@@ -180,6 +197,7 @@ async function main() {
|
|||||||
: undefined,
|
: undefined,
|
||||||
port: serverPort,
|
port: serverPort,
|
||||||
secure: secure === "true",
|
secure: secure === "true",
|
||||||
|
requireTLS: requireTLS === "true",
|
||||||
tls:
|
tls:
|
||||||
ignoreCert == "true"
|
ignoreCert == "true"
|
||||||
? {
|
? {
|
||||||
@@ -188,7 +206,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 = {
|
||||||
|
|||||||
Generated
+5
-5
@@ -8,7 +8,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^3.0.1",
|
"@actions/core": "^3.0.1",
|
||||||
"@actions/glob": "^0.7.0",
|
"@actions/glob": "^0.7.0",
|
||||||
"nodemailer": "^9.1.1",
|
"nodemailer": "^10.0.0",
|
||||||
"showdown": "^2.1.0"
|
"showdown": "^2.1.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -103,12 +103,12 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/nodemailer": {
|
"node_modules/nodemailer": {
|
||||||
"version": "9.1.1",
|
"version": "10.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-9.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-10.0.0.tgz",
|
||||||
"integrity": "sha512-izw9mVKFix6YSnC9eLgV6g1opl9DUlRio9ZNcq+Wu9Ujn2UwF+8Nl0B8nz22kEC+CTZCvinkxwJ0DeFbb6NwcQ==",
|
"integrity": "sha512-wdv+hXBg0iIPIOf108FaZyTxqjQpCvQeAJt9pHHTooPy/y3vQtI9eiImM9AIVKR3e/0FeMA1oueNfBjFJcaK+Q==",
|
||||||
"license": "MIT-0",
|
"license": "MIT-0",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=6.0.0"
|
"node": ">=20.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/showdown": {
|
"node_modules/showdown": {
|
||||||
|
|||||||
+1
-1
@@ -5,7 +5,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^3.0.1",
|
"@actions/core": "^3.0.1",
|
||||||
"@actions/glob": "^0.7.0",
|
"@actions/glob": "^0.7.0",
|
||||||
"nodemailer": "^9.1.1",
|
"nodemailer": "^10.0.0",
|
||||||
"showdown": "^2.1.0"
|
"showdown": "^2.1.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user