Exemplo n.º 1
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.
  *
  * @access  public
  * @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.
  * @return  void
  */
 function sendDirectEmail($issue_id, $from, $to, $cc, $subject, $body, $message_id, $sender_usr_id = false)
 {
     $recipients = Support::getRecipientsCC($cc);
     $recipients[] = $to;
     // send the emails now, one at a time
     foreach ($recipients as $recipient) {
         $mail = new Mail_API();
         if (!empty($issue_id)) {
             // add the warning message to the current message' body, if needed
             $fixed_body = Mail_API::addWarningMessage($issue_id, $recipient, $body);
             $mail->setHeaders(array("Message-Id" => $message_id));
             // skip users who don't have access to this issue
             $recipient_usr_id = User::getUserIDByEmail(Mail_API::getEmailAddress($recipient));
             if (!empty($recipient_usr_id) && !Issue::canAccess($issue_id, $recipient_usr_id) || empty($recipient_usr_id) && Issue::isPrivate($issue_id)) {
                 continue;
             }
         } else {
             $fixed_body = $body;
         }
         if (User::getRoleByUser(User::getUserIDByEmail(Mail_API::getEmailAddress($from)), Issue::getProjectID($issue_id)) == User::getRoleID("Customer")) {
             $type = 'customer_email';
         } else {
             $type = 'other_email';
         }
         $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.
  *
  * @access  private
  * @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
  */
 function _recordNoRecipientError($issue_id, $type, $reminder, $action)
 {
     $to = Reminder::_getReminderAlertAddresses();
     if (count($to) > 0) {
         $tpl = new Template_API();
         $tpl->setTemplate('reminders/alert_no_recipients.tpl.text');
         $tpl->bulkAssign(array("type" => $type, "data" => $data, "reminder" => $reminder, "action" => $action, "conditions" => $conditions, "has_customer_integration" => Customer::hasCustomerIntegration(Issue::getProjectID($issue_id))));
         $text_message = $tpl->getTemplateContents();
         foreach ($to as $address) {
             // send email (use PEAR's classes)
             $mail = new Mail_API();
             $mail->setTextBody($text_message);
             $setup = $mail->getSMTPSettings();
             $mail->send($setup["from"], $address, "[#{$issue_id}] Reminder Not Triggered: " . $action['rma_title'], 0, $issue_id);
         }
     }
 }
Exemplo n.º 3
0
 /**
  * Method used to send the account details of an user.
  *
  * @access  public
  * @param   integer $usr_id The user ID
  * @return  void
  */
 function notifyAccountDetails($usr_id)
 {
     $info = User::getDetails($usr_id);
     $info["projects"] = Project::getAssocList($usr_id, true, true);
     // open text template
     $tpl = new Template_API();
     $tpl->setTemplate('notifications/account_details.tpl.text');
     $tpl->bulkAssign(array("app_title" => Misc::getToolCaption(), "user" => $info));
     $text_message = $tpl->getTemplateContents();
     // send email (use PEAR's classes)
     $mail = new Mail_API();
     $mail->setTextBody($text_message);
     $setup = $mail->getSMTPSettings();
     $mail->send($setup["from"], $mail->getFormattedName($info["usr_full_name"], $info["usr_email"]), APP_SHORT_NAME . ": Your User Account Details");
 }
Exemplo n.º 4
0
 /**
  * Method used to send a confirmation email to the user that is associated
  * to the email address.
  *
  * @access  public
  * @param   string $usr_id The user ID
  * @return  void
  */
 function sendPasswordConfirmationEmail($usr_id)
 {
     $info = User::getDetails($usr_id);
     // send confirmation email to user
     $hash = md5($info["usr_full_name"] . md5($info["usr_email"]) . $GLOBALS["private_key"]);
     $msg = "Hello,\n\n";
     $msg .= "We just received a request to create a new random password for your account in our issue tracking system. ";
     $msg .= "For security reasons we need you to confirm this request so we can finish the password creation process.\n\n";
     $msg .= "If this is not a real request from you, or if you don't need a new password anymore, ";
     $msg .= "please disregard this email.\n\n";
     $msg .= "However, if you would like to confirm this request, please do so by visiting the URL below:\n\n";
     $msg .= APP_BASE_URL . "confirm.php?cat=password&email=" . $info["usr_email"] . "&hash=" . $hash . "\n\n";
     $setup = Setup::load();
     $mail = new Mail_API();
     // need to make this message MIME based
     $mail->setTextBody($msg);
     $mail->send($setup["smtp"]["from"], $info["usr_email"], APP_SHORT_NAME . ": New Password - Confirmation Required");
 }
 /**
  * Notifies site administrators of the error condition
  *
  * @access private
  * @param  mixed $error_msg The error message
  * @param  string $script The script name where the error happened
  * @param  integer $line The line number where the error happened
  */
 function _notify($error_msg = "unknown", $script = "unknown", $line = "unknown")
 {
     global $HTTP_SERVER_VARS;
     $setup = Setup::load();
     $notify_list = trim($setup['email_error']['addresses']);
     if (empty($notify_list)) {
         return false;
     }
     $notify_list = str_replace(';', ',', $notify_list);
     $notify_list = explode(',', $notify_list);
     $subject = APP_SITE_NAME . " - Error found! - " . date("m/d/Y H:i:s");
     $msg = "Hello,\n\n";
     $msg .= "An error was found at " . date("m/d/Y H:i:s") . " (" . time() . ") on line '" . $line . "' of script " . "'{$script}'.\n\n";
     $msg .= "The error message passed to us was:\n\n";
     if (is_array($error_msg) && count($error_msg) > 1) {
         $msg .= "'" . $error_msg[0] . "'\n\n";
         $msg .= "A more detailed error message follows:\n\n";
         $msg .= "'" . $error_msg[1] . "'\n\n";
     } else {
         $msg .= "'{$error_msg}'\n\n";
     }
     @($msg .= "That happened on page '" . $HTTP_SERVER_VARS["PHP_SELF"] . "' from IP Address '" . getenv("REMOTE_ADDR") . "' coming from the page (referrer) '" . getenv("HTTP_REFERER") . "'.\n\n");
     @($msg .= "The user agent given was '" . $HTTP_SERVER_VARS['HTTP_USER_AGENT'] . "'.\n\n");
     $msg .= "Sincerely yours,\nAutomated Error_Handler Class";
     // only try to include the backtrace if we are on PHP 4.3.0 or later
     if (version_compare(phpversion(), "4.3.0", ">=")) {
         $msg .= "\n\nA backtrace is available:\n\n";
         ob_start();
         $backtrace = debug_backtrace();
         // remove the two entries related to the error handling stuff itself
         array_shift($backtrace);
         array_shift($backtrace);
         // now we can print it out
         print_r($backtrace);
         $contents = ob_get_contents();
         $msg .= $contents;
         ob_end_clean();
     }
     // avoid triggering an email notification about a query that
     // was bigger than max_allowed_packet (usually 16 megs on 3.23
     // client libraries)
     if (strlen($msg) > 16777216) {
         return false;
     }
     foreach ($notify_list as $notify_email) {
         $mail = new Mail_API();
         $mail->setTextBody($msg);
         $mail->send($setup['smtp']['from'], $notify_email, $subject);
     }
 }