Example #1
0
 /**
  * Method used to send a confirmation email to the user that is associated
  * to the email address.
  *
  * @param   string $usr_id The user ID
  * @return  void
  */
 public static function sendPasswordConfirmationEmail($usr_id)
 {
     $info = self::getDetails($usr_id);
     // send confirmation email to user
     $hash = md5($info['usr_full_name'] . $info['usr_email'] . Auth::privateKey());
     $tpl = new Template_Helper();
     $tpl->setTemplate('notifications/password_confirmation.tpl.text');
     $tpl->assign(array('app_title' => Misc::getToolCaption(), 'user' => $info, 'hash' => $hash));
     $text_message = $tpl->getTemplateContents();
     $setup = Setup::load();
     $mail = new Mail_Helper();
     // need to make this message MIME based
     $mail->setTextBody($text_message);
     $mail->send($setup['smtp']['from'], $info['usr_email'], APP_SHORT_NAME . ': New Password - Confirmation Required');
 }
Example #2
0
 /**
  * Method used to send emails directly from the sender to the
  * recipient. This will not re-write the sender's email address
  * to issue-xxxx@ or whatever.
  *
  * @param   integer $issue_id The issue ID
  * @param   string $from The sender of this message
  * @param   string $to The primary recipient of this message
  * @param   string $cc The extra recipients of this message
  * @param   string $subject The subject of this message
  * @param   string $body The message body
  * @param   string $message_id The message-id
  * @param   integer $sender_usr_id The ID of the user sending this message.
  * @param   array $attachment An array with attachment information.
  * @return  void
  */
 public function sendDirectEmail($issue_id, $from, $to, $cc, $subject, $body, $attachment, $message_id, $sender_usr_id = false)
 {
     $prj_id = Issue::getProjectID($issue_id);
     $subject = Mail_Helper::formatSubject($issue_id, $subject);
     $recipients = self::getRecipientsCC($cc);
     $recipients[] = $to;
     // send the emails now, one at a time
     foreach ($recipients as $recipient) {
         $mail = new Mail_Helper();
         if (!empty($issue_id)) {
             // add the warning message to the current message' body, if needed
             $fixed_body = Mail_Helper::addWarningMessage($issue_id, $recipient, $body, array());
             $mail->setHeaders(array('Message-Id' => $message_id));
             // skip users who don't have access to this issue (but allow non-users and users without access to this project) to get emails
             $recipient_usr_id = User::getUserIDByEmail(Mail_Helper::getEmailAddress($recipient), true);
             if (!empty($recipient_usr_id) && (!Issue::canAccess($issue_id, $recipient_usr_id) && User::getRoleByUser($recipient_usr_id, $prj_id) != null) || empty($recipient_usr_id) && Issue::isPrivate($issue_id)) {
                 continue;
             }
         } else {
             $fixed_body = $body;
         }
         if (User::getRoleByUser(User::getUserIDByEmail(Mail_Helper::getEmailAddress($from)), Issue::getProjectID($issue_id)) == User::getRoleID('Customer')) {
             $type = 'customer_email';
         } else {
             $type = 'other_email';
         }
         if ($attachment && !empty($attachment['name'][0])) {
             $mail->addAttachment($attachment['name'][0], file_get_contents($attachment['tmp_name'][0]), $attachment['type'][0]);
         }
         $mail->setTextBody($fixed_body);
         $mail->send($from, $recipient, $subject, true, $issue_id, $type, $sender_usr_id);
     }
 }
 /**
  * Method used to send an alert to a set of email addresses when
  * a reminder action was triggered, but no action was really
  * taken because no recipients could be found.
  *
  * @param   integer $issue_id The issue ID
  * @param   string $type Which reminder are we trying to send, email or sms
  * @param   array $reminder The reminder details
  * @param   array $action The action details
  * @return  void
  */
 private function _recordNoRecipientError($issue_id, $type, $reminder, $action, $data, $conditions)
 {
     $to = Reminder::_getReminderAlertAddresses();
     if (count($to) > 0) {
         $tpl = new Template_Helper();
         $tpl->setTemplate('reminders/alert_no_recipients.tpl.text');
         $tpl->assign(array('type' => $type, 'data' => $data, 'reminder' => $reminder, 'action' => $action, 'conditions' => $conditions, 'has_customer_integration' => CRM::hasCustomerIntegration(Issue::getProjectID($issue_id))));
         $text_message = $tpl->getTemplateContents();
         foreach ($to as $address) {
             // send email (use PEAR's classes)
             $mail = new Mail_Helper();
             $mail->setTextBody($text_message);
             $setup = $mail->getSMTPSettings();
             // TRANSLATORS: %1 = issue_id, %2 - rma_title
             $subject = ev_gettext('[#%1$s] Reminder Not Triggered: [#%2$s]', $issue_id, $action['rma_title']);
             $mail->send($setup['from'], $address, $subject, 0, $issue_id);
         }
     }
 }
 /**
  * Notifies site administrators of the error condition
  *
  * @param  string $notify_msg The formatted error message
  * @param  string $notify_from Sender of the email
  * @param  string $notify_list Email addresses to whom send the error report.
  */
 private static function _notify(&$notify_msg, $notify_from, $notify_list)
 {
     $backtrace = debug_backtrace();
     array_splice($backtrace, 0, 2);
     foreach ($backtrace as $frame) {
         // avoid recursion?
         if (isset($frame['class']) && $frame['class'] == __CLASS__) {
             return;
         }
     }
     $time = time();
     $date = date('Y-m-d H:i:s', $time);
     $msg = "Hello,\n\n";
     $msg .= $notify_msg;
     // this checks that we're not running from commandline (cron for example)
     if (isset($_SERVER['REMOTE_ADDR'])) {
         $proto = 'http';
         if (isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] === 'on' || $_SERVER['HTTPS'] == 1)) {
             $proto .= 's';
         }
         $url = "{$proto}://{$_SERVER['HTTP_HOST']}{$_SERVER['SCRIPT_NAME']}";
         if (isset($_SERVER['QUERY_STRING'])) {
             $url .= "?{$_SERVER['QUERY_STRING']}";
         }
         $msg .= "URL: {$url}\n";
         $msg .= "IP: {$_SERVER['REMOTE_ADDR']}\n";
         $login = Auth::getUserLogin();
         if ($login) {
             $msg .= "User: {$login}\n";
         }
         if (!empty($_SERVER['HTTP_REFERER'])) {
             $msg .= "Referer: {$_SERVER['HTTP_REFERER']}\n";
         }
         if (!empty($_SERVER['HTTP_USER_AGENT'])) {
             $msg .= "User-Agent: {$_SERVER['HTTP_USER_AGENT']}\n";
         }
         $msg .= "\n";
     }
     $msg .= "-- \nSincerely yours,\nAutomated Error_Handler Class";
     $max_allowed_packet = DB_Helper::getMaxAllowedPacket();
     // skip error details of an email notification about a query that
     // was bigger than max_allowed_packet + 1024
     if (strlen($msg) > $max_allowed_packet + 1024) {
         return;
     }
     $notify_list = str_replace(';', ',', $notify_list);
     $notify_list = explode(',', $notify_list);
     $subject = APP_SITE_NAME . ' - Error found! - ' . $date;
     foreach ($notify_list as $notify_email) {
         $mail = new Mail_Helper();
         $mail->setTextBody($msg);
         $mail->send($notify_from, $notify_email, $subject, 0, false, 'error');
     }
 }
 /**
  * Method used to send the account details of an user.
  *
  * @param   integer $usr_id The user ID
  * @return  void
  */
 public function notifyAccountDetails($usr_id)
 {
     $info = User::getDetails($usr_id);
     $info['projects'] = Project::getAssocList($usr_id, true, true);
     // open text template
     $tpl = new Template_Helper();
     $tpl->setTemplate('notifications/account_details.tpl.text');
     $tpl->assign(array('app_title' => Misc::getToolCaption(), 'user' => $info));
     Language::set(User::getLang($usr_id));
     $text_message = $tpl->getTemplateContents();
     // send email (use PEAR's classes)
     $mail = new Mail_Helper();
     $mail->setTextBody($text_message);
     $setup = $mail->getSMTPSettings();
     $to = $mail->getFormattedName($info['usr_full_name'], $info['usr_email']);
     // TRANSLATORS: %s = APP_SHORT_NAME
     $subject = ev_gettext('%s: Your User Account Details', APP_SHORT_NAME);
     $mail->send($setup['from'], $to, $subject);
     Language::restore();
 }