mirror of
https://github.com/dawidd6/action-send-mail.git
synced 2024-12-26 11:03:06 +07:00
main: allow two variants of from
This commit is contained in:
parent
b27f0d4766
commit
f00590fc1a
10
main.js
10
main.js
@ -11,6 +11,14 @@ function get_body(body) {
|
|||||||
return body
|
return body
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function get_from(from, username) {
|
||||||
|
if (from.match(/.+<.+@.+>/)) {
|
||||||
|
return from
|
||||||
|
}
|
||||||
|
|
||||||
|
return `"${from}" <${username}>`
|
||||||
|
}
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
try {
|
try {
|
||||||
const server_address = core.getInput("server_address", { required: true })
|
const server_address = core.getInput("server_address", { required: true })
|
||||||
@ -34,7 +42,7 @@ async function main() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const info = await transport.sendMail({
|
const info = await transport.sendMail({
|
||||||
from: from,
|
from: get_from(from, username),
|
||||||
to: to,
|
to: to,
|
||||||
subject: subject,
|
subject: subject,
|
||||||
text: content_type != "text/html" ? get_body(body) : undefined,
|
text: content_type != "text/html" ? get_body(body) : undefined,
|
||||||
|
Loading…
Reference in New Issue
Block a user