/** * Used to add Overwrite send info for testing. * * @return boolean true if mail sent successfully, false if an error */ static function send_test_email($email) { SendPress_Email_Cache::build_cache_for_email($email->emailID); $message = new SendPress_Email(); $message->id($email->emailID); $message->purge(true); $message->subscriber_id($email->subscriberID); $message->list_id($email->listID); $body = $message->html(); $subject = $message->subject(); $to = $email->to_email; $text = $message->text(); if (empty($text) || $text == '' || empty($body) || $body == '' || $body == " ") { SPNL()->log->add('Email Skiped', 'Email id #' . $email->emailID . ' to ' . $to . ' did not have any content. Was the email or template deleted?', 0, 'sending'); return false; } return SendPress_Manager::send($to, $subject, $body, $text, true, $email->subscriberID, $email->listID, $email->emailID); }
static function send_notification($body = "Possible Error With Notifications", $text = "Possible Error With Notifications") { $options = SendPress_Option::get('notification_options'); $senders = array(); if (strlen($options['email']) > 0) { $senders = explode(",", $options['email']); } if ($options['send-to-admins']) { $admins = new WP_User_Query(array('role' => 'Administrator')); foreach ($admins->results as $user) { if ($user->user_email !== $options['email']) { $senders[] = $user->user_email; } } } if ($options['notifications-enable']) { if (is_array($senders) && !empty($senders)) { foreach ($senders as $to) { SendPress_Manager::send(trim($to), 'SendPress Notification', $body, $text); } } } //hipchat if ($options['enable-hipchat'] && strlen($options['hipchat-api']) > 0) { global $hc; $hc = new SendPress_HipChat($options['hipchat-api'], 'https://api.hipchat.com'); try { foreach ($hc->get_rooms() as $room) { if ($options['hipchat-rooms'][$room->room_id]) { $hc->message_room($room->name, 'SendPress', $text, true, "purple", "text"); } } } catch (Exception $e) { $hc->message_room($options['hipchat-room'], 'SendPress', $text, true, "purple", "text"); } } }