The code below is used to send emails to the persons registering on my website.
Currently, the only person receiving the emails is the person who registered, however I'd like an email address e.g. [email protected] to be put in cc of every email.
Does the code below allow that or would it require significant changes?
import { UserModel } from '../user/model';
import { IMessageClient } from '../professional/types';
import { Professional } from '../professional/model';
const charset = 'UTF-8';
function sendSESEmail(
recipient_email: string,
subject: string,
body: string,
cb: (messageId: string, err?: Error) => void,
) {
const aws = require('aws-sdk');
aws.config.region = process.env.AWS_SES_REGION;
const sender = process.env.AWS_SES_SENDER;
const recipient = recipient_email;
const ses = new aws.SES();
const params = {
Source: sender,
Destination: {
ToAddresses: [recipient],
},
Message: {
Subject: {
Data: subject,
Charset: charset,
},
Body: {
Html: {
Data: body,
Charset: charset,
},
},
},
};
ses.sendEmail(params, (error: any, data: any) => {
if (error) cb(undefined, error);
else cb(data.messageId);
});
}
export default function sendEmail(
recipient: string,
subject: string,
body: string,
cb: (err?: Error) => void,
) {
sendSESEmail(recipient, subject, body, (_, err?) => {
cb(err);
});
CodePudding user response:
According to documentation, you only need to add CcAddresses
Destination: {
ToAddresses: [recipient],
CcAddresses: ['[email protected]']
},
or, if you prefer bcc
Destination: {
ToAddresses: [recipient],
BccAddresses: ['[email protected]']
},