/** * @param SproutEmail_CampaignModel $campaign * @param mixed $element Will be an element model most of the time * * @throws Exception * @throws \Exception * @return mixed */ protected function relayNotificationThroughAssignedMailer(SproutEmail_CampaignModel $campaign, $element) { if (!isset($campaign->mailer)) { throw new Exception(Craft::t('An email provider is required to send the notification.')); } $mailer = sproutEmail()->mailers->getMailerByName($campaign->mailer); if (!$mailer) { throw new Exception(Craft::t('The email provider {mailer} is not available.', array('mailer' => $campaign->mailer))); } if (!method_exists($mailer, 'sendNotification')) { throw new Exception(Craft::t('The {mailer} does not have a sendNotification() method.', array('mailer' => get_class($mailer)))); } // Forces campaign.entries to be populated with live entries only $campaign->setLiveEntries(); try { return $mailer->sendNotification($campaign, $element); } catch (\Exception $e) { throw $e; } }