Skip to content

Commit 4847681

Browse files
authored
Made "to" optional (incase cc or bcc is provided) (#183)
* Added made to optional (incase cc or bcc is provided) * updated action.yml
1 parent e3f3ba4 commit 4847681

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

action.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ inputs:
2323
required: true
2424
to:
2525
description: Recipients mail addresses (separated with comma)
26-
required: true
26+
required: false
2727
from:
2828
description: Full name of mail sender (might be with an email address specified in <>)
2929
required: true

main.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ async function main() {
8080

8181
const subject = core.getInput("subject", { required: true })
8282
const from = core.getInput("from", { required: true })
83-
const to = core.getInput("to", { required: true })
83+
const to = core.getInput("to", { required: false })
8484
const body = core.getInput("body", { required: false })
8585
const htmlBody = core.getInput("html_body", { required: false })
8686
const cc = core.getInput("cc", { required: false })
@@ -92,6 +92,11 @@ async function main() {
9292
const ignoreCert = core.getInput("ignore_cert", { required: false })
9393
const priority = core.getInput("priority", { required: false })
9494

95+
// if neither to, cc or bcc is provided, throw error
96+
if (!to && !cc && !bcc) {
97+
throw new Error("At least one of 'to', 'cc' or 'bcc' must be specified")
98+
}
99+
95100
if (!serverAddress) {
96101
throw new Error("Server address must be specified")
97102
}

0 commit comments

Comments
 (0)