k3ntako
k3ntako

Reputation: 51

How to set "to" field (in an email header) to a group email address?

I am using SendGrid in Node.js to send emails to a group of people. THe list is something we maintain on our website. I want the to (aka recipient) field in the email header to show the group email address (e.g., my_group@my_website.com), instead of the recipient email address (e.g., [email protected]). This allow us to separate direct emails from group emails.

In other words, if I receive an email from the group, it should be addressed to the group (e.g., my_group@my_website.com) instead of me in the email header.

When we used Google Groups, we would get the email sent to [group_email]@googlegroups.com, instead of my email address. Below are examples of what happens when an email is sent through Google Groups. I would like some help on replicating that.

This image shows the information associated with a Google Groups email I received. The to field is set to the Google Groups email address, instead of my Gmail address. Gmail email info

I thought it might be just a Google thing, but my Aol email also displays the Google Groups email as for the to field. Aol email info

This is how we are currently sending the email. I understand I can set the to field to anything. However, if I change that to the group email (e.g., my_group@my_website.com), where would we be putting the email addresses of the recipients?

 return sgMail.send({
    to: recipient,
    from: DEFAULT_SENDER,
    subject: renderedMessage.subject,
    html: renderedMessage.html,
    text: renderedMessage.text,
    mailSettings: MAIL_SETTINGS
  });

Upvotes: 0

Views: 328

Answers (1)

k3ntako
k3ntako

Reputation: 51

I figured it out. You just need to BCC (or CC) all the recipients and set the to field to the group email address.

It would look like:

 return sgMail.send({
    to: "[email protected]",
    bcc: recipients,
    from: DEFAULT_SENDER,
    subject: renderedMessage.subject,
    html: renderedMessage.html,
    text: renderedMessage.text,
    mailSettings: MAIL_SETTINGS
  });

Upvotes: 1

Related Questions