Пример #1
0
 /**
  * Send an email with a list of attachments
  *
  * @param mixed $toEmail
  * @param mixed $subject
  * @param mixed $message
  * @param mixed $fromEmail
  * @param mixed $attachments
  */
 public static function sendEmailWithAttachments($toEmail, $subject, $message, $fromEmail = false, $attachments = array(), $ccEmail = false)
 {
     // We allow mutiple emails
     $emails = explode(',', $toEmail);
     $ccEmails = "";
     if (!empty($ccEmail)) {
         $ccEmails = explode(',', $ccEmail);
     }
     if (empty($emails)) {
         return false;
     }
     // Email with template
     $emailBody = $message ? $message : '';
     $emailSubject = $subject ? $subject : '';
     $emailAgent = new Mail_Mail('simple_text', $fromEmail ? false : true);
     $emailAgent->setBody($emailBody)->setSubject($emailSubject);
     if ($fromEmail) {
         $fromName = $fromEmail;
         $userObj = Repo_User::getInstance();
         $user_id = $userObj->emailExists($fromEmail);
         $_user = new Object_User($user_id);
         if (!$_user->getId()) {
             continue;
         }
         $userInfoArr = $_user->getBasicInfo();
         if (!empty($userInfoArr["firstname"]) || !empty($userInfoArr["surname"])) {
             $fromName = trim($userInfoArr["firstname"] . " " . $userInfoArr["surname"]);
         }
         $emailAgent->setFrom($fromName, $fromEmail);
     }
     if (!empty($attachments)) {
         foreach ($attachments as $_a) {
             // Add attachment
             $emailAgent->addAttachment($_a['path'], $_a['name']);
         }
     }
     if (!empty($ccEmail)) {
         foreach ($ccEmails as $_ccEmail) {
             $emailAgent->setCc($_ccEmail, $_ccEmail);
         }
     }
     foreach ($emails as $_toEmail) {
         $emailAgent->setTo($_toEmail);
     }
     try {
         $emailAgent->send();
     } catch (Exception $e) {
         // Ignore for now
     }
     return true;
 }
Пример #2
0
 /**
  * Send an email to presenter himself.
  *
  * @param integer $sessionId
  * return boolean
  */
 public function sendSelfEmail($sessionId)
 {
     $session = new Object_PromoteSession($sessionId);
     if (!$session->getId()) {
         return false;
     }
     $userEmail = Zend_Auth::getInstance()->getIdentity()->email;
     $t = Zend_Registry::getInstance()->translate;
     $emailBody = $t->_('promote-self-email-body');
     $emailBody = str_replace(array('{promoteSessionPresenterLink}'), array(Functions_Common::hostUrl() . '/promote/presenter/session/' . $session->ukey), $emailBody);
     $emailSubject = $t->_('promote-self-email-subject');
     $emailSubject = str_replace(array('{promoteSessionSubject}'), array($this->getValue('subject') . ' ' . date('n/j/y G:i T')), $emailSubject);
     $emailAgent = new Mail_Mail();
     $emailAgent->setBody($emailBody)->setSubject($emailSubject)->setTo($userEmail);
     try {
         $emailAgent->send();
     } catch (Exception $e) {
         // Ignore for now
     }
     return true;
 }
Пример #3
0
 /**
  * Reset password request with email address.
  *
  * @return boolean
  */
 public function resetPasswordRequest($extra_parameters = null)
 {
     // Generate new key
     $newKey = md5($this->getId() . '_' . $this->email . '_' . time());
     $this->password_reset_key = $newKey;
     $this->save();
     $baseResetURL = Functions_Common::hostUrl() . '/login/reset-password/key/';
     $sendingEntity = "";
     //Customize for students if necessary
     if (!is_null($extra_parameters)) {
         if ($extra_parameters->getValue('studentData')) {
             $urlParams = urldecode($extra_parameters->getValue('studentData'));
             $urlParams = json_decode($urlParams);
             $resetSender = $urlParams->resetSender;
             $resetURL = $urlParams->resetUrl;
             $baseResetURL = "http://" . $resetURL . "?reset-password="******" for " . $resetSender;
         }
     }
     // Send out email
     $t = Zend_Registry::getInstance()->translate;
     $emailBody = $t->_('forgot-password-email-body');
     $emailBody = str_replace(array('{resetPasswordLink}'), array($baseResetURL . $this->password_reset_key), $emailBody);
     $emailSubject = $t->_('forgot-password-email-subject') . $sendingEntity;
     $emailAgent = new Mail_Mail();
     $emailAgent->setBody($emailBody)->setSubject($emailSubject)->setTo($this->email);
     try {
         $emailAgent->send();
     } catch (Exception $e) {
         return false;
     }
     return true;
 }