使用Sendgrid Web API每周发送一次简报

时间:2013-03-07 07:47:52

标签: php sendgrid

我正在使用PHP开发一个项目,我正在使用sendgrid web API。其中,我希望用户在指定的日期每周或每月发送一次通讯。

我不知道如何在sendgrid上管理它。 任何人都可以帮助我,并为我提供解决方案。

3 个答案:

答案 0 :(得分:1)

您正在寻找新闻稿API,此处记录了这些内容:

  

http://sendgrid.com/docs/API_Reference/Newsletter_API/index.html

具体来说,您可以使用API​​来安排使用计划终结点的交付:

  

http://sendgrid.com/docs/API_Reference/Newsletter_API/schedule.html

没有PHP包装器,因此您需要使用curl或类似的东西发出请求。

答案 1 :(得分:0)

从这里下载Sendgrid PHP包装器:

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


   include 'path/to/sendgrid-php/SendGrid_loader.php';

   //Initialize the SendGrid object with your SendGrid credentials:
   $sendgrid = new SendGrid('username', 'password');

   //Create a new SendGrid Mail object and add your message details
   $mail = new SendGrid\Mail();
   $mail->
   addTo('foo@bar.com')->
   setFrom('me@bar.com')->
   setSubject('Subject goes here')->
   setText('Hello World!')->
   setHtml('Hello World!');

   //Send it using the Web API like so:
   $sendgrid->
   web->
   send($mail);


在此处查看Sendgrid API文档 http://sendgrid.com/docs/Code_Examples/php.html

编辑:

在服务器上设置cron作业,以便每周或每月运行此脚本。

答案 2 :(得分:0)

Sendgrid不提供任何此类服务。

如果您想要处理此重复发送的简报,那么您可以通过管理服务器上的数据库和cron作业进行管理。

相关问题