mirror of
https://github.com/dawidd6/action-send-mail.git
synced 2025-07-09 16:40:30 +07:00
Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
dc13c734ff | |||
48476814b0 | |||
e3f3ba4f86 | |||
19516a4a58 |
4
.github/workflows/test.yml
vendored
4
.github/workflows/test.yml
vendored
@ -42,7 +42,7 @@ jobs:
|
|||||||
html_body: file://README.md
|
html_body: file://README.md
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
- name: Send mail
|
- name: Send mail
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
@ -63,7 +63,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
- name: Send mail
|
- name: Send mail
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
|
@ -60,6 +60,10 @@ Some features:
|
|||||||
attachments: attachments.zip,git.diff,./dist/static/*.js
|
attachments: attachments.zip,git.diff,./dist/static/*.js
|
||||||
# Optional priority: 'high', 'normal' (default) or 'low'
|
# Optional priority: 'high', 'normal' (default) or 'low'
|
||||||
priority: low
|
priority: low
|
||||||
|
# Optional nodemailerlog: true/false
|
||||||
|
nodemailerlog: false
|
||||||
|
# Optional nodemailerdebug: true/false if true lognodem will also be set true
|
||||||
|
nodemailerdebug: false
|
||||||
```
|
```
|
||||||
|
|
||||||
## Troubleshooting
|
## Troubleshooting
|
||||||
|
@ -23,7 +23,7 @@ inputs:
|
|||||||
required: true
|
required: true
|
||||||
to:
|
to:
|
||||||
description: Recipients mail addresses (separated with comma)
|
description: Recipients mail addresses (separated with comma)
|
||||||
required: true
|
required: false
|
||||||
from:
|
from:
|
||||||
description: Full name of mail sender (might be with an email address specified in <>)
|
description: Full name of mail sender (might be with an email address specified in <>)
|
||||||
required: true
|
required: true
|
||||||
@ -57,6 +57,12 @@ inputs:
|
|||||||
priority:
|
priority:
|
||||||
description: Set Priority level for the mail message to 'high', 'normal' (default) or 'low'
|
description: Set Priority level for the mail message to 'high', 'normal' (default) or 'low'
|
||||||
required: false
|
required: false
|
||||||
|
nodemailerlog:
|
||||||
|
description: Log option for nodemailer
|
||||||
|
required: false
|
||||||
|
nodemailerdebug:
|
||||||
|
description: Debug option for nodemailer
|
||||||
|
required: false
|
||||||
runs:
|
runs:
|
||||||
using: node16
|
using: node16
|
||||||
main: main.js
|
main: main.js
|
||||||
|
15
main.js
15
main.js
@ -80,7 +80,7 @@ async function main() {
|
|||||||
|
|
||||||
const subject = core.getInput("subject", { required: true })
|
const subject = core.getInput("subject", { required: true })
|
||||||
const from = core.getInput("from", { required: true })
|
const from = core.getInput("from", { required: true })
|
||||||
const to = core.getInput("to", { required: true })
|
const to = core.getInput("to", { required: false })
|
||||||
const body = core.getInput("body", { required: false })
|
const body = core.getInput("body", { required: false })
|
||||||
const htmlBody = core.getInput("html_body", { required: false })
|
const htmlBody = core.getInput("html_body", { required: false })
|
||||||
const cc = core.getInput("cc", { required: false })
|
const cc = core.getInput("cc", { required: false })
|
||||||
@ -91,15 +91,18 @@ async function main() {
|
|||||||
const convertMarkdown = core.getInput("convert_markdown", { required: false })
|
const convertMarkdown = core.getInput("convert_markdown", { required: false })
|
||||||
const ignoreCert = core.getInput("ignore_cert", { required: false })
|
const ignoreCert = core.getInput("ignore_cert", { required: false })
|
||||||
const priority = core.getInput("priority", { required: false })
|
const priority = core.getInput("priority", { required: false })
|
||||||
|
const nodemailerlog = core.getInput("nodemailerlog", { required: false })
|
||||||
|
const nodemailerdebug = core.getInput("nodemailerdebug", { required: false })
|
||||||
|
|
||||||
|
// if neither to, cc or bcc is provided, throw error
|
||||||
|
if (!to && !cc && !bcc) {
|
||||||
|
throw new Error("At least one of 'to', 'cc' or 'bcc' must be specified")
|
||||||
|
}
|
||||||
|
|
||||||
if (!serverAddress) {
|
if (!serverAddress) {
|
||||||
throw new Error("Server address must be specified")
|
throw new Error("Server address must be specified")
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!username || !password) {
|
|
||||||
core.warning("Username and password not specified. You should only do this if you are using a self-hosted runner to access an on-premise mail server.")
|
|
||||||
}
|
|
||||||
|
|
||||||
const transport = nodemailer.createTransport({
|
const transport = nodemailer.createTransport({
|
||||||
host: serverAddress,
|
host: serverAddress,
|
||||||
auth: username && password ? {
|
auth: username && password ? {
|
||||||
@ -111,6 +114,8 @@ async function main() {
|
|||||||
tls: ignoreCert == "true" ? {
|
tls: ignoreCert == "true" ? {
|
||||||
rejectUnauthorized: false
|
rejectUnauthorized: false
|
||||||
} : undefined,
|
} : undefined,
|
||||||
|
logger: nodemailerdebug == "true" ? true : nodemailerlog,
|
||||||
|
debug: nodemailerdebug,
|
||||||
})
|
})
|
||||||
|
|
||||||
const info = await transport.sendMail({
|
const info = await transport.sendMail({
|
||||||
|
Reference in New Issue
Block a user