Adding Multiple Recipients using Sendgrid marketing Email in PHP


Hi I am using Sendgrid marketing email API to send bulk of emails.Here i need to add multiple recipients in the list. I have seen lots of answers but i am not clear with any answer. This is the code I'm using to add single email to the list.

$data=array('email'=>'[email protected]',
'data'=>  json_encode($data)

In the above code, how can i change the data array, so that I can be able to add multiple email recipients address




You would pretty much need a&data[]= param for each recipient you need added to your list. That's why you'd have to loop through your data, like this:

$email = array('[email protected]','[email protected]');
$name = array('andrei1','andrei2');
   $data[] = json_encode(array('email' => $email[$i],
               'name' => $name[$i]

$url = '';

$params = array(
          'api_user' => 'SENDGRID_USERNAME',
          'api_key' => 'SENDGRID_PASSWORD',
          'list' => 'Test list',
          'data' => $data[$i]
$request =  $url.'api/newsletter/lists/email/add.json';

People are also looking for solutions to the problem: php - apache displaying some really strange characters


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.