2014-04-08 143 views
6

我使用sendgrid和php,我使用了客戶端庫和curl選項。到目前爲止,我已經能夠通過addTo選項直接發送電子郵件,沒有任何問題。但是,當我嘗試添加抄送或密件抄送選項時,電子郵件仍會發送,但副本從未發送。是否有任何已知的PHP版本問題?在其他項目中,Java庫工作得很好。SendGrid抄送和密件抄送不能在PHP

下面是一段簡單的代碼,我試圖使它工作

<?php 
require ('sendgrid/sendgrid-php.php'); 

$sendgrid = new SendGrid('user', 'pwd'); 

$mail = new SendGrid\Email(); 
$mail ->addTo("[email protected]"); 
$mail ->addCc("[email protected]"); 
$mail ->setFrom("[email protected]"); 
$mail ->setSubject("TEST"); 
$mail->setHtml("<h1>Example</h1>"); 
$sendgrid->send($mail); 

?> 
+0

的var_dump($電子郵件)和後輸出 – Hackerman

回答

7

文檔似乎並不具有addCc方法。 你可以嘗試這些替代方案。

$mail = new SendGrid\Email(); 
$mail->addTo('[email protected]')-> 
     addTo('[email protected]')-> 
     addTo('[email protected]'); 

$mail = new SendGrid\Email(); 
$mail->addBcc('[email protected]'); 
$sendgrid->send($mail); 

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

+0

多AddTo就不會把戲模仿密件抄送,但是我需要的電子郵件與他們各自的發送抄送和密送。 addCc方法沒有出現在文檔中,但它在庫上。 – Mike

+0

他們已經從文檔中刪除了addCc。 https://github.com/sendgrid/sendgrid-php/commit/7d5e428321db6419829eb52a206364b072182d81 – comrade

+0

你也可以在這裏chk這個問題。 https://github.com/sendgrid/sendgrid-php/issues/83 – comrade