/**
  * 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);
         }
     }
 }
Ejemplo n.º 2
0
 /**
  * Connects to the SMTP server and sends the queued message.
  *
  * @access  private
  * @param   string $recipient The recipient of this message
  * @param   string $text_headers The full headers of this message
  * @param   string $body The full body of this message
  * @return  true, or a PEAR_Error object
  */
 function _sendEmail($recipient, $text_headers, $body)
 {
     $header_names = Mime_Helper::getHeaderNames($text_headers);
     $_headers = Mail_Queue::_getHeaders($text_headers, $body);
     $headers = array();
     foreach ($_headers as $lowercase_name => $value) {
         // need to remove the quotes to avoid a parsing problem
         // on senders that have extended characters in the first
         // or last words in their sender name
         if ($lowercase_name == 'from') {
             $value = Mime_Helper::removeQuotes($value);
         }
         $value = Mime_Helper::encode($value);
         // add the quotes back
         if ($lowercase_name == 'from') {
             $value = Mime_Helper::quoteSender($value);
         }
         $headers[$header_names[$lowercase_name]] = $value;
     }
     // remove any Reply-To:/Return-Path: values from outgoing messages
     unset($headers['Reply-To']);
     unset($headers['Return-Path']);
     // mutt sucks, so let's remove the broken Mime-Version header and add the proper one
     if (in_array('Mime-Version', array_keys($headers))) {
         unset($headers['Mime-Version']);
         $headers['MIME-Version'] = '1.0';
     }
     $mail =& Mail::factory('smtp', Mail_API::getSMTPSettings());
     $res = $mail->send($recipient, $headers, $body);
     if (PEAR::isError($res)) {
         // special handling of errors when the mail server is down
         if (strstr($res->getMessage(), 'unable to connect to smtp server')) {
             Error_Handler::logToFile(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
         } else {
             Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
         }
         return $res;
     } else {
         return true;
     }
 }
Ejemplo n.º 3
0
 /**
  * Since Mail::prepareHeaders() is not supposed to be called statically, this method
  * instantiates an instance of the mail class and calls prepareHeaders on it.
  *
  * @param array $headers The array of headers to prepare, in an associative
  *              array, where the array key is the header name (ie,
  *              'Subject'), and the array value is the header
  *              value (ie, 'test'). The header produced from those
  *              values would be 'Subject: test'.
  * @return mixed Returns false if it encounters a bad address,
  *               otherwise returns an array containing two
  *               elements: Any From: address found in the headers,
  *               and the plain text version of the headers.
  */
 function prepareHeaders($headers)
 {
     $params = Mail_API::getSMTPSettings();
     $mail =& Mail::factory('smtp', $params);
     return $mail->prepareHeaders($headers);
 }
Ejemplo n.º 4
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");
 }