Max
Max

Reputation: 51

Mailjet : Send Cc or Bcc mail with Mailjet Send API

I'm using Mailjet Send API.

I can send emails by using this part ofcode :

$body = [
          'Messages' => [
            [
              'From' => [
                'Email' => "$fromm",
                'Name' => "$namee"
              ],
              'To' => [
                [
                  'Email' => "$to",
                  'Name' => ""
                ]
              ]
              'Subject' => "$subject",
              'TextPart' => "$text",
              'HTMLPart' => "$confirmationMail",
              'CustomID' => "AppGettingStartedTest"
            ]
          ]
        ];
        $response = $mj->post(Resources::$Email, ['body' => $body]);
        $response->success();
        $success=$response->getData()["Messages"][0]["Status"];

But if I want to add a Cc or Bcc, like :

 $body = [
      'Messages' => [
        [
          'From' => [
            'Email' => "$fromm",
            'Name' => "$namee"
          ],
          'To' => [
            [
              'Email' => "$to",
              'Name' => ""
            ]
          ],
          'Cc' => [
            [
                'Email' => "$cc",
                'Name' => ""
            ]
        ],
        'Bcc' => [
            [
                'Email' => "$cci",
                'Name' => ""
            ]
        ],
          'Subject' => "$subject",
          'TextPart' => "$text",
          'HTMLPart' => "$confirmationMail",
          'CustomID' => "AppGettingStartedTest"
        ]
      ]
    ];

then it does not work anymore. However the documentation seems to stipulate it's the right way : here

Any idea how to solve this ?

Many thanks.

Upvotes: 5

Views: 2292

Answers (1)

flosej
flosej

Reputation: 139

For properties To, Cc and Bcc, use comma separated recipients instead.

Optionally, in place of Recipients, you can use To, Cc and Bcc properties. To, Cc and Bcc can't be used in conjunction with Recipients. The properties can contain several recipients separated by comma using the following format [email protected], <[email protected]> or "John Doe" <[email protected]>

Only Recipients accepts an array of recipients with name and email.

https://dev.mailjet.com/email/guides/send-api-V3/

Upvotes: 0

Related Questions