Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
1.2 kB
3
Indexable
Never
# ------------------
# Create a campaign
# ------------------
# Include the Brevo library
require_once(__DIR__ . "/APIv3-php-library/autoload.php");
# Instantiate the client
Sendinblue\Client\Configuration::getDefaultConfiguration()->setApiKey("api-key", "YOUR_API_V3_KEY");
$api_instance = new Sendinblue\Client\Api\EmailCampaignsApi();
$emailCampaigns = new \Sendinblue\Client\Model\CreateEmailCampaign();
# Define the campaign settings
$email_campaigns['name'] = "Campaign sent via the API";
$email_campaigns['subject'] = "My subject";
$email_campaigns['sender'] = array("name": "From name", "email":"myfromemail@mycompany.com");
$email_campaigns['type'] = "classic";
# Content that will be sent
"htmlContent"=> "Congratulations! You successfully sent this example campaign via the Brevo API.",
# Select the recipients
"recipients"=> array("listIds"=> [2, 7]),
# Schedule the sending in one hour
"scheduledAt"=> "2018-01-01 00:00:01"
);
# Make the call to the client
try {
$result = $api_instance->createEmailCampaign($emailCampaigns);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling EmailCampaignsApi->createEmailCampaign: ', $e->getMessage(), PHP_EOL;
}