use SendGrid;
use SendGrid\Mail\To;
class SendGridController extends Controller
{
public function register(Request $request)
{
// ... your rego code
$apiKey = 'YOUR_API_KEY';
$sg = new SendGrid($apiKey);
$list_id = 'YOUR_LIST_ID';
//Add an email to the list
$email = new To();
$email->setEmail($request->input('email'));
$email->setFirstName($request->input('first_name'));
$email->setLastName($request->input('last_name'));
$response = $sg->client->marketing()->lists()->recipients()->post($list_id, $email->jsonSerialize());
return $response->statusCode();
}
}
2条答案
按热度按时间bzzcjhmw1#
你可以使用SendGrid PHP包来实现这个功能,下面是一个例子来说明你是如何做到的:
在Laravel的注册控制器中:
您还可以参考SendGrid API documentation,了解有关如何创建、更新和删除列表以及添加和删除收件人的详细信息。
3j86kqsm2#
can be done与sendgrid-php包: