Google App Engine发送网格PHP附件

时间:2016-08-12 18:22:15

标签: google-app-engine sendgrid

我正在尝试添加https://github.com/sendgrid/sendgrid-google-php所示的附件。但它不通过这种方式工作。我想我尝试了所有可能的解决方案但是无法做到这一点。这是我的代码。

<?php
require 'SendGrid_loader.php';

// Connect to your SendGrid account
$sendgrid = new SendGrid\SendGrid('myusername', 'mypassword');

// Make a message object
$mail = new SendGrid\Mail();

// Mail arrayi
$emails = array("mailadress1@test.com","mailadress2@test.com");
$names  = array("name1", "name2");


// Add recipients and other message details
$mail->setTos($emails)->
       setFrom('testsender@test.com')->
       setFromName('Test Sender')->
       setReplyTo('testemail@test.com')->
       setSubject('Test')->
       addAttachment("test.jpg")->
       addCategory("TEST-GONDERIM")->
       addUniqueArgument("BASIN", "YEREL-BASIN")->
       addSubstitution("%name%", $names)->
       setText('TEXT BODY MESSAGE')->
       setHtml('<strong>%name% MERHABA,</br>BODY MESSAGE</strong>');

// Use the Web API to send your message
$sendgrid->send($mail);
?>

我试图将test.jpg文件放在与此php文件相同的文件夹中。还尝试添加像gs://bucket_name/test.jpg但不工作。有任何想法吗。提前致谢

0 个答案:

没有答案