function mailchimp_campaign_send_test_campaign in Mailchimp 7.4
Same name and namespace in other branches
- 7.5 modules/mailchimp_campaign/mailchimp_campaign.module \mailchimp_campaign_send_test_campaign()
- 7.3 modules/mailchimp_campaign/mailchimp_campaign.module \mailchimp_campaign_send_test_campaign()
Send Mailchimp campaign.
1 call to mailchimp_campaign_send_test_campaign()
- mailchimp_campaign_send_test_form_submit in modules/
mailchimp_campaign/ includes/ mailchimp_campaign.admin.inc - Submit handler for mailchimp_campaign_send_test_form().
File
- modules/
mailchimp_campaign/ mailchimp_campaign.module, line 452 - Module file for mailchimp_campaign.
Code
function mailchimp_campaign_send_test_campaign(MailChimpCampaign $campaign, $recipients = array()) {
/* @var \Mailchimp\MailchimpCampaigns $mc_campaigns */
$mc_campaigns = mailchimp_get_api_object('MailchimpCampaigns');
try {
if (!$mc_campaigns) {
throw new MailchimpException('Cannot send campaign without Mailchimp API. Check API key has been entered.');
}
$mc_campaigns
->sendTest($campaign->mc_campaign_id, $recipients, \Mailchimp\MailchimpCampaigns::EMAIL_TYPE_HTML);
// Log action, and notify the user.
watchdog('mailchimp_campaign', 'Mailchimp test message for campaign %name has been sent to %recipients.', array(
'%name' => $campaign
->label(),
'%recipients' => implode(', ', $recipients),
), WATCHDOG_INFO);
return TRUE;
} catch (Exception $e) {
drupal_set_message($e
->getMessage(), 'error');
watchdog('mailchimp_campaign', 'An error occurred while sending a test of this campaign: %message', array(
'%message' => $e
->getMessage(),
), WATCHDOG_ERROR);
}
return FALSE;
}