fix: hook up cc and bcc fields to mail sender

This commit is contained in:
Ahmed Bouhuolia
2024-11-02 19:33:29 +02:00
parent bd5e33855a
commit 51905825fd
5 changed files with 23 additions and 3 deletions

View File

@@ -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[]) {

View File

@@ -126,7 +126,6 @@ export class SendSaleEstimateMail {
mailOptions: SaleEstimateMailOptions
): Promise<SaleEstimateMailOptions> => {
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.

View File

@@ -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,

View File

@@ -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 = {

View File

@@ -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.