diff --git a/packages/server/src/lib/Mail/index.ts b/packages/server/src/lib/Mail/index.ts index 015ca02a82..8310d594ea 100644 --- a/packages/server/src/lib/Mail/index.ts +++ b/packages/server/src/lib/Mail/index.ts @@ -9,6 +9,8 @@ export default class Mail { subject: string = ''; content: string = ''; to: string | string[]; + cc: string | string[]; + bcc: string | string[]; from: string = `${process.env.MAIL_FROM_NAME} ${process.env.MAIL_FROM_ADDRESS}`; data: { [key: string]: string | number }; attachments: IMailAttachment[]; @@ -20,6 +22,8 @@ export default class Mail { return { to: this.to, from: this.from, + cc: this.cc, + bcc: this.bcc, subject: this.subject, html: this.html, attachments: this.attachments, @@ -60,6 +64,16 @@ export default class Mail { return this; } + setCC(cc: string | string[]) { + this.cc = cc; + return this; + } + + setBCC(bcc: string | string[]) { + this.bcc = bcc; + return this; + } + /** * Sets from address to the mail. * @param {string} from @@ -72,7 +86,7 @@ export default class Mail { /** * Set attachments to the mail. - * @param {IMailAttachment[]} attachments + * @param {IMailAttachment[]} attachments * @returns {Mail} */ setAttachments(attachments: IMailAttachment[]) { diff --git a/packages/server/src/services/Sales/Estimates/SendSaleEstimateMail.ts b/packages/server/src/services/Sales/Estimates/SendSaleEstimateMail.ts index 697a4993eb..1c1ada66aa 100644 --- a/packages/server/src/services/Sales/Estimates/SendSaleEstimateMail.ts +++ b/packages/server/src/services/Sales/Estimates/SendSaleEstimateMail.ts @@ -126,7 +126,6 @@ export class SendSaleEstimateMail { mailOptions: SaleEstimateMailOptions ): Promise => { const formatterArgs = await this.formatterArgs(tenantId, saleEstimateId); - const formattedOptions = await this.contactMailNotification.formatMailOptions( tenantId, @@ -166,6 +165,8 @@ export class SendSaleEstimateMail { const mail = new Mail() .setSubject(formattedOptions.subject) .setTo(formattedOptions.to) + .setCC(formattedOptions.cc) + .setBCC(formattedOptions.bcc) .setContent(formattedOptions.message); // Attaches the estimate pdf to the mail. diff --git a/packages/server/src/services/Sales/Invoices/SendSaleInvoiceMail.ts b/packages/server/src/services/Sales/Invoices/SendSaleInvoiceMail.ts index cee271fcd2..2d2a454242 100644 --- a/packages/server/src/services/Sales/Invoices/SendSaleInvoiceMail.ts +++ b/packages/server/src/services/Sales/Invoices/SendSaleInvoiceMail.ts @@ -77,6 +77,8 @@ export class SendSaleInvoiceMail { const mail = new Mail() .setSubject(formattedMessageOptions.subject) .setTo(formattedMessageOptions.to) + .setCC(formattedMessageOptions.cc) + .setBCC(formattedMessageOptions.bcc) .setContent(formattedMessageOptions.message); // Attach invoice document. @@ -89,7 +91,6 @@ export class SendSaleInvoiceMail { { filename: `${invoiceFilename}.pdf`, content: invoicePdfBuffer }, ]); } - const eventPayload = { tenantId, saleInvoiceId, diff --git a/packages/server/src/services/Sales/PaymentReceived/PaymentReceivedMailNotification.ts b/packages/server/src/services/Sales/PaymentReceived/PaymentReceivedMailNotification.ts index 49276f8c13..7cd045f34e 100644 --- a/packages/server/src/services/Sales/PaymentReceived/PaymentReceivedMailNotification.ts +++ b/packages/server/src/services/Sales/PaymentReceived/PaymentReceivedMailNotification.ts @@ -135,6 +135,8 @@ export class SendPaymentReceiveMailNotification { const mail = new Mail() .setSubject(parsedMessageOpts.subject) .setTo(parsedMessageOpts.to) + .setCC(parsedMessageOpts.cc) + .setBCC(parsedMessageOpts.bcc) .setContent(parsedMessageOpts.message); const eventPayload = { diff --git a/packages/server/src/services/Sales/Receipts/SaleReceiptMailNotification.ts b/packages/server/src/services/Sales/Receipts/SaleReceiptMailNotification.ts index 7683c6c81c..81ca4c19e3 100644 --- a/packages/server/src/services/Sales/Receipts/SaleReceiptMailNotification.ts +++ b/packages/server/src/services/Sales/Receipts/SaleReceiptMailNotification.ts @@ -139,6 +139,8 @@ export class SaleReceiptMailNotification { const mail = new Mail() .setSubject(parsedMessageOpts.subject) .setTo(parsedMessageOpts.to) + .setCC(parsedMessageOpts.cc) + .setBCC(parsedMessageOpts.bcc) .setContent(parsedMessageOpts.message); // Attaches the receipt pdf document.