SendGrid Cc and Bcc do not work in PHP

I use sendgrid with php, I used both options - the client library and the curl parameter. So far, I could send messages directly using the addTo option without any problems. But when I try to add the Cc or Bcc options, the email is still sent, but the copies are not delivered. Are there any known issues with php version? In another project, the java library works very well.

Here is a simple piece of code I'm trying to do.

<?php require ('sendgrid/sendgrid-php.php'); $sendgrid = new SendGrid('user', 'pwd'); $mail = new SendGrid\Email(); $mail ->addTo(" mymail@gmail.com "); $mail ->addCc(" other@otherserver.com "); $mail ->setFrom(" sender@server.com "); $mail ->setSubject("TEST"); $mail->setHtml("<h1>Example</h1>"); $sendgrid->send($mail); ?> 
+6
source share
1 answer

There is no addCc method in the documentation. You can try these alternatives.

 $mail = new SendGrid\Email(); $mail->addTo(' foo@bar.com ')-> addTo(' someotheraddress@bar.com ')-> addTo(' another@another.com '); 

or

 $mail = new SendGrid\Email(); $mail->addBcc(' foo@bar.com '); $sendgrid->send($mail); 

https://github.com/sendgrid/sendgrid-php#bcc

+7
source

All Articles