CC and BCC interface
This commit is contained in:
parent
623ecbd36e
commit
1b49f02092
|
@ -21,6 +21,14 @@ exports.definition = {
|
|||
type: "string",
|
||||
title: "Send From",
|
||||
},
|
||||
cc: {
|
||||
type: "string",
|
||||
title: "CC",
|
||||
},
|
||||
bcc: {
|
||||
type: "string",
|
||||
title: "BCC",
|
||||
},
|
||||
subject: {
|
||||
type: "string",
|
||||
title: "Email Subject",
|
||||
|
@ -49,13 +57,21 @@ exports.definition = {
|
|||
}
|
||||
|
||||
exports.run = async function ({ inputs }) {
|
||||
let { to, from, subject, contents } = inputs
|
||||
let { to, from, subject, contents, cc, bcc } = inputs
|
||||
if (!contents) {
|
||||
contents = "<h1>No content</h1>"
|
||||
}
|
||||
to = to || undefined
|
||||
try {
|
||||
let response = await sendSmtpEmail(to, from, subject, contents, true)
|
||||
let response = await sendSmtpEmail(
|
||||
to,
|
||||
from,
|
||||
subject,
|
||||
contents,
|
||||
cc,
|
||||
bcc,
|
||||
true
|
||||
)
|
||||
return {
|
||||
success: true,
|
||||
response,
|
||||
|
|
|
@ -54,7 +54,15 @@ async function checkResponse(response, errorMsg, { ctx } = {}) {
|
|||
exports.request = request
|
||||
|
||||
// have to pass in the tenant ID as this could be coming from an automation
|
||||
exports.sendSmtpEmail = async (to, from, subject, contents, automation) => {
|
||||
exports.sendSmtpEmail = async (
|
||||
to,
|
||||
from,
|
||||
subject,
|
||||
contents,
|
||||
cc,
|
||||
bcc,
|
||||
automation
|
||||
) => {
|
||||
// tenant ID will be set in header
|
||||
const response = await fetch(
|
||||
checkSlashesInUrl(env.WORKER_URL + `/api/global/email/send`),
|
||||
|
@ -65,6 +73,8 @@ exports.sendSmtpEmail = async (to, from, subject, contents, automation) => {
|
|||
from,
|
||||
contents,
|
||||
subject,
|
||||
cc,
|
||||
bcc,
|
||||
purpose: "custom",
|
||||
automation,
|
||||
},
|
||||
|
|
|
@ -10,6 +10,8 @@ exports.sendEmail = async ctx => {
|
|||
contents,
|
||||
from,
|
||||
subject,
|
||||
cc,
|
||||
bcc,
|
||||
automation,
|
||||
} = ctx.request.body
|
||||
let user
|
||||
|
@ -23,6 +25,8 @@ exports.sendEmail = async ctx => {
|
|||
contents,
|
||||
from,
|
||||
subject,
|
||||
cc,
|
||||
bcc,
|
||||
automation,
|
||||
})
|
||||
ctx.body = {
|
||||
|
|
|
@ -12,7 +12,13 @@ function buildEmailSendValidation() {
|
|||
return joiValidator.body(Joi.object({
|
||||
email: Joi.string().email({
|
||||
multiple: true,
|
||||
}),
|
||||
}),
|
||||
cc: Joi.string().email({
|
||||
multiple: true,
|
||||
}),
|
||||
bcc: Joi.string().email({
|
||||
multiple: true,
|
||||
}),
|
||||
purpose: Joi.string().valid(...Object.values(EmailTemplatePurpose)),
|
||||
workspaceId: Joi.string().allow("", null),
|
||||
from: Joi.string().allow("", null),
|
||||
|
|
Loading…
Reference in New Issue