Reputation: 99
I'm working on a functionality where once a user signs up for an account, he will start getting a series of email throughout a time period (email drips).
I'm using Laravel. I need to grab the email on sign up and save it on an email list on SendGrid. But I don't find this on the sendgrid/sendgrid-php
package's docs.
So, would you please tell me how I may implement this?
Upvotes: 0
Views: 248
Reputation: 25161
It can be done with the sendgrid-php package:
use SendGrid;
$api = new SendGrid(YOUR_API_KEY);
$contacts = [
[
'email' => "email@something",
'address_line_1' => '',
'city' => '',
'country' => '',
'first_name' => '',
'last_name' => '',
etc....
]
]
$request_body = [
'contacts' => $contacts
];
$response = $api->client->marketing()->contacts()->put($request_body);
if($response->statusCode() !== 202) {
// error has occured
}
Upvotes: 1