mirror of
https://github.com/dawidd6/action-send-mail.git
synced 2024-12-26 19:13:06 +07:00
main: log transport
This commit is contained in:
parent
72d529bf7f
commit
4effcb0f30
12
main.js
12
main.js
@ -2,7 +2,7 @@ const nodemailer = require("nodemailer")
|
|||||||
const core = require("@actions/core")
|
const core = require("@actions/core")
|
||||||
const fs = require("fs")
|
const fs = require("fs")
|
||||||
|
|
||||||
function get_body(body) {
|
function getBody(body) {
|
||||||
if (body.startsWith("file://")) {
|
if (body.startsWith("file://")) {
|
||||||
const file = body.replace("file://", "")
|
const file = body.replace("file://", "")
|
||||||
return fs.readFileSync(file, "utf8")
|
return fs.readFileSync(file, "utf8")
|
||||||
@ -11,7 +11,7 @@ function get_body(body) {
|
|||||||
return body
|
return body
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_from(from, username) {
|
function getFrom(from, username) {
|
||||||
if (from.match(/.+<.+@.+>/)) {
|
if (from.match(/.+<.+@.+>/)) {
|
||||||
return from
|
return from
|
||||||
}
|
}
|
||||||
@ -42,12 +42,14 @@ async function main() {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
console.log(transport)
|
||||||
|
|
||||||
const info = await transport.sendMail({
|
const info = await transport.sendMail({
|
||||||
from: get_from(from, username),
|
from: getFrom(from, username),
|
||||||
to: to,
|
to: to,
|
||||||
subject: subject,
|
subject: subject,
|
||||||
text: content_type != "text/html" ? get_body(body) : undefined,
|
text: content_type != "text/html" ? getBody(body) : undefined,
|
||||||
html: content_type == "text/html" ? get_body(body) : undefined,
|
html: content_type == "text/html" ? getBody(body) : undefined,
|
||||||
attachments: attachments ? attachments.split(',').map(f => ({ path: f.trim() })) : undefined
|
attachments: attachments ? attachments.split(',').map(f => ({ path: f.trim() })) : undefined
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user