我正在使用 PHP 开发一个项目,其中我使用的是 sendgrid Web API。其中,我想在每周或每月的指定日期由用户发送时事通讯。
我不知道如何在 sendgrid 上管理这个。任何人都可以帮助我并给我解决方案。
您正在寻找时事通讯 API,此处记录了该 API:
http://sendgrid.com/docs/API_Reference/Newsletter_API/index.html
具体来说,您可以使用 API 使用 schedule 端点来安排交付:
http://sendgrid.com/docs/API_Reference/Newsletter_API/schedule.html
没有 PHP 包装器,因此您需要使用 curl 或类似的东西发出请求。
Sendgrid 不提供任何此类服务。
如果您想处理定期发送的时事通讯,那么您可以通过管理数据库和服务器上的 cron 作业来进行管理。
Download Sendgrid PHP wrapper from here :
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);
Check Sendgrid API documentation here http://sendgrid.com/docs/Code_Examples/php.html
Edit:
Setup cron job on the server to run this script weekly or monthly.