You are here

function mailchimp_campaign_send_campaign in Mailchimp 7.2

Same name and namespace in other branches
  1. 8 modules/mailchimp_campaign/mailchimp_campaign.module \mailchimp_campaign_send_campaign()
  2. 7.5 modules/mailchimp_campaign/mailchimp_campaign.module \mailchimp_campaign_send_campaign()
  3. 7.3 modules/mailchimp_campaign/mailchimp_campaign.module \mailchimp_campaign_send_campaign()
  4. 7.4 modules/mailchimp_campaign/mailchimp_campaign.module \mailchimp_campaign_send_campaign()
  5. 2.x modules/mailchimp_campaign/mailchimp_campaign.module \mailchimp_campaign_send_campaign()

Send MailChimp campaign.

1 call to mailchimp_campaign_send_campaign()
mailchimp_campaign_send_form_submit in modules/mailchimp_campaign/mailchimp_campaign.admin.inc
Submit handler for mailchimp_campaign_delete_list_form();

File

modules/mailchimp_campaign/mailchimp_campaign.module, line 259

Code

function mailchimp_campaign_send_campaign(MailChimpCampaign $campaign) {
  $mcapi = mailchimp_get_api_object();

  // Send campaign.
  $sent = $mcapi
    ->campaignSendNow($campaign->mc_campaign_id);
  if ($mcapi->errorCode) {

    // Display and log error, if any.
    $message = 'MailChimp error. The campaign was not sent.';
    _mailchimp_campaign_mcapi_error_message($mcapi, $message);
  }
  if ($sent) {

    // Log action, and notify the user.
    watchdog('mailchimp_campaign', 'MailChimp campaign %name has been sent.', array(
      '%name' => $campaign
        ->label(),
    ));
  }
  return $sent;
}