feat: adds cc field to email
This commit is contained in:
@@ -45,6 +45,8 @@ const sendEmail = async (beforeChangeData: any, formConfig: PluginConfig) => {
|
||||
message,
|
||||
subject,
|
||||
emailTo,
|
||||
cc: emailCC,
|
||||
bcc: emailBCC,
|
||||
emailFrom,
|
||||
emailFromName,
|
||||
replyTo: emailReplyTo,
|
||||
@@ -52,13 +54,17 @@ const sendEmail = async (beforeChangeData: any, formConfig: PluginConfig) => {
|
||||
} = email;
|
||||
|
||||
const to = replaceDoubleCurlys(emailTo, submissionData);
|
||||
const cc = emailCC ? replaceDoubleCurlys(emailCC, submissionData) : '';
|
||||
const bcc = emailBCC ? replaceDoubleCurlys(emailBCC, submissionData) : '';
|
||||
const from = replaceDoubleCurlys(emailFromName ? `"${emailFromName}" ` + emailFrom : emailFrom, submissionData);
|
||||
const replyTo = replaceDoubleCurlys(replyToName ? `"${replyToName}" ` + emailReplyTo : emailReplyTo || emailFrom, submissionData);
|
||||
const replyTo = replaceDoubleCurlys(replyToName ? `"${replyToName}" ` + emailReplyTo : emailReplyTo || emailFrom, submissionData);
|
||||
|
||||
if (to && from) {
|
||||
return ({
|
||||
to,
|
||||
from,
|
||||
cc,
|
||||
bcc,
|
||||
replyTo,
|
||||
subject: replaceDoubleCurlys(subject, submissionData),
|
||||
html: `<div>${serialize(message, submissionData)}</div>`
|
||||
@@ -72,7 +78,6 @@ const sendEmail = async (beforeChangeData: any, formConfig: PluginConfig) => {
|
||||
if (typeof beforeEmail === 'function') {
|
||||
emailsToSend = await beforeEmail(formattedEmails);
|
||||
}
|
||||
|
||||
const log = emailsToSend.map(({ html, ...rest }) => ({ ...rest }))
|
||||
|
||||
await Promise.all(
|
||||
|
||||
@@ -155,10 +155,18 @@ export const generateFormCollection = (formConfig: PluginConfig): CollectionConf
|
||||
label: 'Email To',
|
||||
required: true,
|
||||
admin: {
|
||||
width: '50%',
|
||||
width: '100%',
|
||||
placeholder: 'Email Sender <sender@email.com>'
|
||||
},
|
||||
},
|
||||
{
|
||||
type: 'text',
|
||||
name: 'cc',
|
||||
label: 'CC',
|
||||
admin: {
|
||||
width: '50%',
|
||||
},
|
||||
},
|
||||
{
|
||||
type: 'text',
|
||||
name: 'bcc',
|
||||
|
||||
@@ -157,6 +157,7 @@ export type Email = {
|
||||
emailTo: string
|
||||
emailFrom: string
|
||||
emailFromName?: string
|
||||
cc?: string
|
||||
bcc?: string
|
||||
replyTo?: string
|
||||
replyToName?: string
|
||||
@@ -166,6 +167,8 @@ export type Email = {
|
||||
|
||||
export type FormattedEmail = {
|
||||
to: string
|
||||
cc?: string
|
||||
bcc?: string
|
||||
from: string
|
||||
subject: string
|
||||
html: string
|
||||
|
||||
Reference in New Issue
Block a user