Sendgrid-php: Notice: Array to String Conversion on addCC (Sendgrid Version 2.2.1)

Created on 27 Oct 2017  路  4Comments  路  Source: sendgrid/sendgrid-php

Whenever I add "addCC" to the code below. I always receive an error which is "Notice: Array to String Conversion", but when I remove "addCC", the code works.

The error appears to be line 51 in lib/SendGrid.php which is: curl_setopt($ch, CURLOPT_POSTFIELDS, $form);

$sendgrid_email->addTo($receiver_email)-> addCC("[email protected]", "[email protected]")-> setFrom($sender_email)-> setFromName("Email Sender")-> setSubject($subject)-> setHtml($email_content)-> addHeader("X-Sent-Using", "SendGrid-API")-> addHeader("X-Transport", "web");

Is there any fix for this error?

The code is written in PHP

medium hacktoberfest help wanted question

Most helpful comment

@rsalunga29 I think the problem is in addCc method. You try to add multiple CC but method expected only one. You should use addCcs method instead.

All 4 comments

Maybe it is a deserialization issue?

@mbernier Not sure, I haven't found the cause of the problem yet. If ever the error is in deserialization, what would be the fix for this?

@rsalunga29 I think the problem is in addCc method. You try to add multiple CC but method expected only one. You should use addCcs method instead.

@misantron that what I did :). Thanks for your input!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jverlee picture jverlee  路  4Comments

micahwalter picture micahwalter  路  3Comments

KayakinKoder picture KayakinKoder  路  5Comments

moontrv picture moontrv  路  3Comments

rainman0607 picture rainman0607  路  4Comments