mirror of
https://github.com/dawidd6/action-send-mail.git
synced 2024-12-26 19:13:06 +07:00
main: try catch block
This commit is contained in:
parent
fced312130
commit
ae7db41acb
56
main.js
56
main.js
@ -12,35 +12,39 @@ function get_body(body) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
server_address = core.getInput("server_address", {required: true})
|
try {
|
||||||
server_port = core.getInput("server_port", {required: true})
|
server_address = core.getInput("server_address", { required: true })
|
||||||
username = core.getInput("username", {required: true})
|
server_port = core.getInput("server_port", { required: true })
|
||||||
password = core.getInput("password", {required: true})
|
username = core.getInput("username", { required: true })
|
||||||
subject = core.getInput("subject", {required: true})
|
password = core.getInput("password", { required: true })
|
||||||
body = core.getInput("body", {required: true})
|
subject = core.getInput("subject", { required: true })
|
||||||
to = core.getInput("to", {required: true})
|
body = core.getInput("body", { required: true })
|
||||||
from = core.getInput("from", {required: true})
|
to = core.getInput("to", { required: true })
|
||||||
html = core.getInput("html") || "false"
|
from = core.getInput("from", { required: true })
|
||||||
|
html = core.getInput("html") || "false"
|
||||||
|
|
||||||
transport = nodemailer.createTransport({
|
transport = nodemailer.createTransport({
|
||||||
host: server_address,
|
host: server_address,
|
||||||
port: server_port,
|
port: server_port,
|
||||||
secure: server_port == "465",
|
secure: server_port == "465",
|
||||||
auth: {
|
auth: {
|
||||||
user: username,
|
user: username,
|
||||||
pass: password,
|
pass: password,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
info = await transport.sendMail({
|
info = await transport.sendMail({
|
||||||
from: `"${from}" <${username}>`,
|
from: `"${from}" <${username}>`,
|
||||||
to: to,
|
to: to,
|
||||||
subject: subject,
|
subject: subject,
|
||||||
text: html == "false" ? get_body(body) : undefined,
|
text: html == "false" ? get_body(body) : undefined,
|
||||||
html: html == "true" ? get_body(body) : undefined,
|
html: html == "true" ? get_body(body) : undefined,
|
||||||
})
|
})
|
||||||
|
|
||||||
console.log(info)
|
console.log(info)
|
||||||
|
} catch (error) {
|
||||||
|
core.setFailed(error.message)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
main()
|
main()
|
Loading…
Reference in New Issue
Block a user