Problems with sending CC and BCC copies using the Resend API

135 Views Asked by At

The problem I'm facing is that I pass the email addresses, the body, the subject, CC, and BCC as parameters, but I'm experiencing issues. I mean, I input valid email addresses and everything, but the emails only reach the primary recipient, and not the copies. I don't understand why, and I'm not sure if it's something related to RESEND or if I'm doing something wrong. It's strange because the emails do get sent, but when I check the RESEND logs, they don't appear to have been sent to the CC and BCC fields, even though I've included them, and the POST methods show that all this data was input. It's possible that I'm using the free version of RESEND, which may limit my ability to do this, or I might need to set up a domain. I hope you can provide some insights." this is my code: import {Resend} from 'resend'

export default class ResendController {

     static async sendmail (req, res ){

        try {
            const { TO,subject, body, CC, CCO } = req.body; 

            const resend = new Resend(process.env.API_KEY);
      
            const emailData = ({
              from: '[email protected]', 
              to: TO, 
              subject: subject,
              html: body,
              cc: CC,
              bcc: CCO
            });
            
            const emailResponse = await resend.emails.send(emailData);

            if (emailResponse && emailResponse.name === 'validation_error') {
              return res.status(422).json({ message: 'Error en la validación de correo', error: emailResponse.message });
            }
            res.status(200).json({ message: 'Correo enviado con éxito', emailData});
            
          } catch (error) {
            res.status(500).json({ message: 'Error al enviar el correo', error: error.message });
          }
        }
 }
POSTMAN:{
  "TO":"[email protected]",
  "subject": "xd",
  "body": "hola",
  "CC":"[email protected]",
   "CCO": "[email protected]"
}

I hope to receive a helpful response or a solution to my problem, or more information since there is very little information available regarding RESEND.

0

There are 0 best solutions below