Skip to content

Calling add_bcc after creating a mail intance fails. #507

@ManuelSaleta

Description

@ManuelSaleta

When I create a Mail.new and this instance includes the to property.

I will get the following error when trying to call, add_bcc

email client responded with: -- {:response=>#<SendGrid::Response:0x0000000121b09b50 @status_code="400", @body="{\"errors\":[{\"message\":\"The to array is required for all personalization objects, and must have at least one email object with a valid email address.\",\"field\":\"personalizations.1.to\",\"help\":\"http://sendgrid.com/docs/API_Reference/Web_API_v3/Mail/errors.html#message.personalizations.to\"}]}", @headers={"server"=>["nginx"], "date"=>["Fri, 26 Sep 2025 16:24:27 GMT"], "content-type"=>["application/json"], "content-length"=>["288"], "connection"=>["close"], "access-control-allow-origin"=>["https://sendgrid.api-docs.io"], "access-control-allow-methods"=>["POST"], "access-control-allow-headers"=>["Authorization, Content-Type, On-behalf-of, x-sg-elas-acl"], "access-control-max-age"=>["600"], "x-no-cors-reason"=>["https://sendgrid.com/docs/Classroom/Basics/API/cors.html"], "strict-transport-security"=>["max-age=31536000; includeSubDomains"], "content-security-policy"=>["frame-ancestors 'none'"], "cache-control"=>["no-cache"], "x-content-type-options"=>["no-sniff"], "referrer-policy"=>["strict-origin-when-cross-origin"]}>}

This happens when you try to call add_bcc to an mail instance, after having added a to parameter when building an email...

I found a work around by calling .add_to as part of personalization..
by including add_to as part of the personalization

              email.add_personalization(
                SendGrid::Personalization.new.tap do |p|
                  p.add_to(to_recipient)
                  p.add_bcc(bcc_recipient)
                end
              )

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions