🤘 Implementation for #59 to support username and password as optional (#60)

Co-authored-by: Dawid Dziurla <dawidd0811@gmail.com>
This commit is contained in:
Javier de Pedro López
2021-06-14 20:04:27 +02:00
committed by GitHub
parent 98b61f505d
commit db36373cbe
4 changed files with 22 additions and 28 deletions

22
main.js
View File

@ -33,8 +33,8 @@ async function main() {
try {
const serverAddress = core.getInput("server_address", { required: true })
const serverPort = core.getInput("server_port", { required: true })
const username = core.getInput("username", { required: true })
const password = core.getInput("password", { required: true })
const username = core.getInput("username")
const password = core.getInput("password")
const subject = core.getInput("subject", { required: true })
const from = core.getInput("from", { required: true })
const to = core.getInput("to", { required: true })
@ -48,17 +48,21 @@ async function main() {
const convertMarkdown = core.getInput("convert_markdown", { required: false })
const ignoreCert = core.getInput("ignore_cert", { required: false })
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({
host: serverAddress,
port: serverPort,
secure: secure ? true : serverPort == "465",
auth: {
auth: username && password ? {
user: username,
pass: password,
},
tls: ignoreCert ? {
pass: password
} : undefined,
port: serverPort,
secure: secure == "true" ? true : serverPort == "465",
tls: ignoreCert == "true" ? {
rejectUnauthorized: false
} : undefined
} : undefined,
})
const info = await transport.sendMail({