/**
  * adds a mail to the queue
  * @param type $to
  * @param type $mime_headers
  * @param type $body
  * @return type
  */
 public static function add($to, $mime_headers, $body)
 {
     rb::connectExisting();
     $bean = rb::getBean('mailerqueue');
     $bean->to = $to;
     $bean->mimeheaders = serialize($mime_headers);
     $bean->body = $body;
     $bean->sendtime = self::getDateTime();
     $bean->sent = 0;
     $bean->domain = helpers::getDomain($to);
     return R::store($bean);
 }
 /**
  * 
  * @param imap $imap 
  * @param type $x
  */
 public function parseMessage($imap, $x)
 {
     $imap->mail->noop();
     try {
         $message = $imap->mail->getMessage($x);
     } catch (Exception $e) {
         log::error($e->getMessage());
         return false;
     }
     $imap->mail->noop();
     $parts = $imap->getAllParts($message);
     // check for valid message/delivery-status'
     if (!isset($parts['message/delivery-status'][0])) {
         log::debug("No delivery status");
         return false;
     } else {
         $delivery_status = $parts['message/delivery-status'][0];
     }
     $email = self::getBounceEmail($delivery_status);
     if ($email) {
         log::error("Found email in message: {$email}");
         $bean = rb::getBean('mailerbounce');
         $bean->deleted = 0;
         // get bounce code e.g 4.4.2 hotmail
         $bounce_code = trim(self::getBounceCode($delivery_status));
         if ($bounce_code) {
             $bounce_ary = explode('.', $bounce_code);
             $bean->major = $bounce_ary[0];
             $bean->minor = $bounce_ary[1];
             $bean->part = $bounce_ary[2];
             $bean->bouncecode = $bounce_code;
         } else {
             $bean->bouncecode = null;
         }
         $bean->email = $email;
         $bean->bouncedate = date::getDateNow(array('hms' => true));
         $bean->message = $delivery_status;
         $bean->returnpath = $message->getHeader('return-path', 'string');
         R::store($bean);
         log::debug("Stored user with email: {$email}. {$bounce_code}" . PHP_EOL);
     } else {
         log::error("Did not get a mail from message: " . $delivery_status);
     }
     return true;
 }
Exemple #3
0
 public function addToDb($ary)
 {
     foreach ($ary as $val) {
         $b = rb::getBean('account', 'email', $val[1]);
         $b->username = $val[0];
         $b->email = \diversen\strings\mb::tolower($val[1]);
         $b->password = md5('secret1972');
         $b->type = 'email';
         $b->verified = 1;
         rb::commitBean($b);
     }
     foreach ($ary as $val) {
         $b = rb::getBean('allowed', 'email', $val[1]);
         $b->username = $val[0];
         $b->email = \diversen\strings\mb::tolower($val[1]);
         $b->type = 'email';
         rb::commitBean($b);
     }
 }
Exemple #4
0
 /**
  * Create a 'hel' and all 'helmembers'
  * @param array $ary _POST
  * @return boolean $res result from R::store
  */
 public function createHel($ary)
 {
     $e = new eDb();
     // create hel
     $hel = rb::getBean('hel');
     $hel->user_id = session::getUserId();
     // Attach halve ids
     $my_halv = $e->getUserHalvFromUserId(session::getUserId());
     $hel->halv_a = $ary['halv'];
     $hel->halv_b = $my_halv['id'];
     // Attach all 8 members
     $hel = $this->attachMembersForHel($hel, $ary);
     return R::store($hel);
 }
Exemple #5
0
 /**
  * /event/user/halv
  */
 public function helAction()
 {
     $this->checkAccess();
     $eDb = new eDb();
     $halv = $eDb->getUserHalvFromUserId(session::getUserId());
     if (empty($halv)) {
         http::locationHeader('/event/user/index', 'Du skal være del af en halv kvadrille for at oprette en hel');
     }
     http::prg();
     if (isset($_POST['send'])) {
         $this->validateHel();
         if (empty($this->errors)) {
             // Prepare
             $ary = db::prepareToPostArray(array('halv'), true);
             R::begin();
             // Delete other hele
             $eDb->deleteHelFromUserId(session::getUserId());
             // Create
             $id = $eDb->createHel($ary);
             // Set a better name
             $name = $eDb->getUsersStrFromHel($id);
             $bean = rb::getBean('hel', 'id', $id);
             $bean->name = $name;
             R::store($bean);
             $res = R::commit();
             if (!$res) {
                 R::rollback();
             }
             http::locationHeader('/event/user/index');
         } else {
             echo html::getErrors($this->errors);
         }
     }
     echo $this->formCreateHel();
 }