Made "to" optional (incase cc or bcc is provided) (#183)

* Added made to optional (incase cc or bcc is provided)

* updated action.yml
This commit is contained in:
Jatin Dehmiwal 2023-09-27 12:19:06 +05:30 committed by GitHub
parent e3f3ba4f86
commit 48476814b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View File

@ -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

View File

@ -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 })
@ -92,6 +92,11 @@ async function main() {
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 })
// 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")
} }