@@ -44,7 +44,6 @@ function sparkpostSend()
4444 'timeout ' => 15 ,
4545 'headers ' => $ this ->get_request_headers (),
4646 'body ' => json_encode ($ this ->get_request_body ())
47-
4847 );
4948
5049 $ http = _wp_http_get_object ();
@@ -224,8 +223,18 @@ protected function get_recipients()
224223 'address ' => array (
225224 'email ' => $ to [0 ],
226225 'name ' => $ to [1 ]
227- ));
226+ )
227+ );
228228 }
229+
230+ // add bcc to recipients
231+ // sparkposts recipients list acts as bcc by default
232+ $ bcc = $ this ->get_bcc ();
233+
234+ if (!empty ($ bcc )) {
235+ $ recipients = array_merge ($ recipients , $ bcc );
236+ }
237+
229238 return $ recipients ;
230239 }
231240
@@ -259,6 +268,24 @@ protected function get_reply_to()
259268 return implode (', ' , $ replyTos );
260269 }
261270
271+ /**
272+ * Returns the list of BCC headers
273+ * @return array
274+ */
275+ protected function get_bcc ()
276+ {
277+ $ bcc = array ();
278+ foreach ($ this ->getBccAddresses () as $ bccAddress ) {
279+ $ bcc [] = array (
280+ 'address ' => array (
281+ 'email ' => $ bccAddress [0 ],
282+ 'name ' => $ bccAddress [1 ],
283+ )
284+ );
285+ }
286+ return $ bcc ;
287+ }
288+
262289 /**
263290 * Returns a collection that can be sent as headers in body
264291 * @return array
@@ -271,6 +298,7 @@ protected function get_headers()
271298 );
272299 $ headers = $ this ->createHeader ();
273300
301+
274302 $ formatted_headers = new StdClass ();
275303 // split by line separator
276304 foreach (explode ($ this ->LE , $ headers ) as $ line ) {
0 commit comments