public function markSent(OrganiserEmailModel $organiserEmailModel)
 {
     global $DB;
     $stat = $DB->prepare("UPDATE organiser_email SET sent_at=:sent_at WHERE id=:id");
     $stat->execute(array('id' => $organiserEmailModel->getId(), 'sent_at' => \TimeSource::getFormattedForDataBase()));
 }
$customFields = $site->getCachedEventCustomFieldDefinitionsAsModels();
$customFieldOrganiserEmail = $customFields[0];
$userRepo = new \repositories\UserAccountRepository();
$organiserEmailRepo = new \com\meetyournextmp\repositories\OrganiserEmailRepository();
configureAppForSite($site);
$nowPlusSomeEmailReadingTime = TimeSource::getDateTime();
$nowPlusSomeEmailReadingTime->add(new \DateInterval("P1D"));
// Events
$erb = new \repositories\builders\EventRepositoryBuilder();
$erb->setSite($site);
$erb->setAfterNow();
$erb->setIncludeCancelled(false);
$erb->setIncludeDeleted(false);
foreach ($erb->fetchAll() as $event) {
    print $event->getSlug() . " " . $event->getSummary() . "\n";
    $email = \com\meetyournextmp\models\OrganiserEmailModel::getEmailFrom($event->getCustomField($customFieldOrganiserEmail));
    if ($email) {
        print "  -  email: " . $email . "\n";
        if ($event->getStartAtInUTC()->getTimestamp() < $nowPlusSomeEmailReadingTime->getTimestamp()) {
            print "  - event to soon, not sending\n";
        } else {
            print "  - event not to soon\n";
            $organiserEmailFoundInHistory = false;
            $hrb = new \repositories\builders\HistoryRepositoryBuilder();
            $hrb->setEvent($event);
            foreach ($hrb->fetchAll() as $history) {
                if ($history->getUserAccountId()) {
                    $user = $userRepo->loadByID($history->getUserAccountId());
                    if ($user && $user->getEmail() == $email) {
                        $organiserEmailFoundInHistory = true;
                    }