main: log transport

This commit is contained in:
Dawid Dziurla 2020-09-24 10:24:29 +02:00 committed by GitHub
parent 72d529bf7f
commit 4effcb0f30
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

12
main.js
View File

@ -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
}) })