diff --git a/packages/plugin-form-builder/src/collections/FormSubmissions/hooks/sendEmail.ts b/packages/plugin-form-builder/src/collections/FormSubmissions/hooks/sendEmail.ts
index 826e586e84..97edb1d4a4 100644
--- a/packages/plugin-form-builder/src/collections/FormSubmissions/hooks/sendEmail.ts
+++ b/packages/plugin-form-builder/src/collections/FormSubmissions/hooks/sendEmail.ts
@@ -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: `
${serialize(message, submissionData)}
`
@@ -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(
diff --git a/packages/plugin-form-builder/src/collections/Forms/index.ts b/packages/plugin-form-builder/src/collections/Forms/index.ts
index c0bc39fa7f..471520e256 100644
--- a/packages/plugin-form-builder/src/collections/Forms/index.ts
+++ b/packages/plugin-form-builder/src/collections/Forms/index.ts
@@ -155,10 +155,18 @@ export const generateFormCollection = (formConfig: PluginConfig): CollectionConf
label: 'Email To',
required: true,
admin: {
- width: '50%',
+ width: '100%',
placeholder: 'Email Sender '
},
},
+ {
+ type: 'text',
+ name: 'cc',
+ label: 'CC',
+ admin: {
+ width: '50%',
+ },
+ },
{
type: 'text',
name: 'bcc',
diff --git a/packages/plugin-form-builder/src/types.ts b/packages/plugin-form-builder/src/types.ts
index 8d091acd8a..2755e3860d 100644
--- a/packages/plugin-form-builder/src/types.ts
+++ b/packages/plugin-form-builder/src/types.ts
@@ -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