diff --git a/action.yml b/action.yml index b9992737..407d2c54 100644 --- a/action.yml +++ b/action.yml @@ -23,7 +23,7 @@ inputs: required: true to: description: Recipients mail addresses (separated with comma) - required: true + required: false from: description: Full name of mail sender (might be with an email address specified in <>) required: true diff --git a/main.js b/main.js index 907d5f2c..dd556eda 100644 --- a/main.js +++ b/main.js @@ -80,7 +80,7 @@ async function main() { const subject = core.getInput("subject", { 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 htmlBody = core.getInput("html_body", { 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 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) { throw new Error("Server address must be specified") }