2021-05-11 16:08:59 +02:00
|
|
|
const { sendSmtpEmail } = require("../../utilities/workerRequests")
|
|
|
|
|
2021-09-06 18:53:02 +02:00
|
|
|
exports.definition = {
|
2021-05-11 16:08:59 +02:00
|
|
|
description: "Send an email using SMTP",
|
|
|
|
tagline: "Send SMTP email to {{inputs.to}}",
|
2021-09-07 15:32:43 +02:00
|
|
|
icon: "Email",
|
2021-05-11 16:08:59 +02:00
|
|
|
name: "Send Email (SMTP)",
|
|
|
|
type: "ACTION",
|
2021-09-14 13:40:19 +02:00
|
|
|
internal: true,
|
2021-05-11 16:08:59 +02:00
|
|
|
stepId: "SEND_EMAIL_SMTP",
|
|
|
|
inputs: {},
|
|
|
|
schema: {
|
|
|
|
inputs: {
|
|
|
|
properties: {
|
|
|
|
to: {
|
|
|
|
type: "string",
|
|
|
|
title: "Send To",
|
|
|
|
},
|
|
|
|
from: {
|
|
|
|
type: "string",
|
|
|
|
title: "Send From",
|
|
|
|
},
|
|
|
|
subject: {
|
|
|
|
type: "string",
|
|
|
|
title: "Email Subject",
|
|
|
|
},
|
|
|
|
contents: {
|
|
|
|
type: "string",
|
|
|
|
title: "HTML Contents",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
required: ["to", "from", "subject", "contents"],
|
|
|
|
},
|
|
|
|
outputs: {
|
|
|
|
properties: {
|
|
|
|
success: {
|
|
|
|
type: "boolean",
|
|
|
|
description: "Whether the email was sent",
|
|
|
|
},
|
|
|
|
response: {
|
|
|
|
type: "object",
|
|
|
|
description: "A response from the email client, this may be an error",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
required: ["success"],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2021-09-06 18:53:02 +02:00
|
|
|
exports.run = async function ({ inputs }) {
|
2021-05-11 16:08:59 +02:00
|
|
|
let { to, from, subject, contents } = inputs
|
|
|
|
if (!contents) {
|
|
|
|
contents = "<h1>No content</h1>"
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
let response = await sendSmtpEmail(to, from, subject, contents)
|
|
|
|
return {
|
|
|
|
success: true,
|
|
|
|
response,
|
|
|
|
}
|
|
|
|
} catch (err) {
|
|
|
|
return {
|
|
|
|
success: false,
|
|
|
|
response: err,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|