main: allow two variants of from

This commit is contained in:
Dawid Dziurla 2020-03-25 16:18:35 +01:00 committed by GitHub
parent b27f0d4766
commit f00590fc1a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

10
main.js
View File

@ -11,6 +11,14 @@ function get_body(body) {
return body
}
function get_from(from, username) {
if (from.match(/.+<.+@.+>/)) {
return from
}
return `"${from}" <${username}>`
}
async function main() {
try {
const server_address = core.getInput("server_address", { required: true })
@ -34,7 +42,7 @@ async function main() {
})
const info = await transport.sendMail({
from: from,
from: get_from(from, username),
to: to,
subject: subject,
text: content_type != "text/html" ? get_body(body) : undefined,