public static function sendNotificationToAdmin($args)
 {
     list($idsite, $idvisitor, $message) = $args;
     $visitorInfo = ChatPersonnalInformation::get($idvisitor);
     $subject = "New message on " . ChatSite::getSiteName($idsite);
     $mail = new Mail();
     $mail->setFrom(Config::getInstance()->General['noreply_email_address'], "Piwik Chat");
     $mail->setSubject($subject);
     $mail->setBodyHtml("Name : " . $visitorInfo['name'] . "<br />\n        Email : " . $visitorInfo['email'] . "<br />\n        Phone : " . $visitorInfo['phone'] . "<br />\n        Comments : " . $visitorInfo['comments'] . "<br />\n        <br /><br />\n        Message:<br />{$message}");
     foreach (ChatCommon::getUsersBySite($idsite) as $user) {
         if (empty($user['email'])) {
             continue;
         }
         if (ChatPiwikUser::isStaffOnline($user['login'])) {
             continue;
         }
         $mail->addTo($user['email']);
         try {
             $mail->send();
         } catch (Exception $e) {
             throw new Exception("An error occured while sending '{$subject}' " . " to " . implode(', ', $mail->getRecipients()) . ". Error was '" . $e->getMessage() . "'");
         }
         $mail->clearRecipients();
     }
 }
Beispiel #2
0
 private function sendMail($subject, $body)
 {
     $feedbackEmailAddress = Config::getInstance()->General['feedback_email_address'];
     $subject = '[ Feedback Feature - Piwik ] ' . $subject;
     $body = Common::unsanitizeInputValue($body) . "\n" . 'Piwik ' . Version::VERSION . "\n" . 'IP: ' . IP::getIpFromHeader() . "\n" . 'URL: ' . Url::getReferrer() . "\n";
     $mail = new Mail();
     $mail->setFrom(Piwik::getCurrentUserEmail());
     $mail->addTo($feedbackEmailAddress, 'Piwik Team');
     $mail->setSubject($subject);
     $mail->setBodyText($body);
     @$mail->send();
 }
Beispiel #3
0
 /**
  * Sends email confirmation link for a password reset request.
  *
  * @param array $user User info for the requested password reset.
  */
 private function sendEmailConfirmationLink($user)
 {
     $login = $user['login'];
     $email = $user['email'];
     // construct a password reset token from user information
     $resetToken = self::generatePasswordResetToken($user);
     $ip = IP::getIpFromHeader();
     $url = Url::getCurrentUrlWithoutQueryString() . "?module=Login&action=confirmResetPassword&login="******"&resetToken=" . urlencode($resetToken);
     // send email with new password
     $mail = new Mail();
     $mail->addTo($email, $login);
     $mail->setSubject(Piwik::translate('Login_MailTopicPasswordChange'));
     $bodyText = str_replace('\\n', "\n", sprintf(Piwik::translate('Login_MailPasswordChangeBody'), $login, $ip, $url)) . "\n";
     $mail->setBodyText($bodyText);
     $fromEmailName = Config::getInstance()->General['login_password_recovery_email_name'];
     $fromEmailAddress = Config::getInstance()->General['login_password_recovery_email_address'];
     $mail->setFrom($fromEmailAddress, $fromEmailName);
     $replytoEmailName = Config::getInstance()->General['login_password_recovery_replyto_email_name'];
     $replytoEmailAddress = Config::getInstance()->General['login_password_recovery_replyto_email_address'];
     $mail->setReplyTo($replytoEmailAddress, $replytoEmailName);
     @$mail->send();
 }
 public function sendReport($reportType, $report, $contents, $filename, $prettyDate, $reportSubject, $reportTitle, $additionalFiles)
 {
     if (self::manageEvent($reportType)) {
         $periods = self::getPeriodToFrequencyAsAdjective();
         $message = Piwik::translate('ScheduledReports_EmailHello');
         $subject = Piwik::translate('General_Report') . ' ' . $reportTitle . " - " . $prettyDate;
         $mail = new Mail();
         $mail->setSubject($subject);
         $fromEmailName = Config::getInstance()->branding['use_custom_logo'] ? Piwik::translate('CoreHome_WebAnalyticsReports') : Piwik::translate('ScheduledReports_PiwikReports');
         $fromEmailAddress = Config::getInstance()->General['noreply_email_address'];
         $attachmentName = $subject;
         $mail->setFrom($fromEmailAddress, $fromEmailName);
         $displaySegmentInfo = false;
         $segmentInfo = null;
         $segment = API::getSegment($report['idsegment']);
         if ($segment != null) {
             $displaySegmentInfo = true;
             $segmentInfo = Piwik::translate('ScheduledReports_SegmentAppliedToReports', $segment['name']);
         }
         switch ($report['format']) {
             case 'html':
                 // Needed when using images as attachment with cid
                 $mail->setType(Zend_Mime::MULTIPART_RELATED);
                 $message .= "<br/>" . Piwik::translate('ScheduledReports_PleaseFindBelow', array($periods[$report['period']], $reportTitle));
                 if ($displaySegmentInfo) {
                     $message .= " " . $segmentInfo;
                 }
                 $mail->setBodyHtml($message . "<br/><br/>" . $contents);
                 break;
             default:
             case 'pdf':
                 $message .= "\n" . Piwik::translate('ScheduledReports_PleaseFindAttachedFile', array($periods[$report['period']], $reportTitle));
                 if ($displaySegmentInfo) {
                     $message .= " " . $segmentInfo;
                 }
                 $mail->setBodyText($message);
                 $mail->createAttachment($contents, 'application/pdf', Zend_Mime::DISPOSITION_INLINE, Zend_Mime::ENCODING_BASE64, $attachmentName . '.pdf');
                 break;
         }
         foreach ($additionalFiles as $additionalFile) {
             $fileContent = $additionalFile['content'];
             $at = $mail->createAttachment($fileContent, $additionalFile['mimeType'], Zend_Mime::DISPOSITION_INLINE, $additionalFile['encoding'], $additionalFile['filename']);
             $at->id = $additionalFile['cid'];
             unset($fileContent);
         }
         // Get user emails and languages
         $reportParameters = $report['parameters'];
         $emails = array();
         if (isset($reportParameters[self::ADDITIONAL_EMAILS_PARAMETER])) {
             $emails = $reportParameters[self::ADDITIONAL_EMAILS_PARAMETER];
         }
         if ($reportParameters[self::EMAIL_ME_PARAMETER] == 1) {
             if (Piwik::getCurrentUserLogin() == $report['login']) {
                 $emails[] = Piwik::getCurrentUserEmail();
             } elseif ($report['login'] == Piwik::getSuperUserLogin()) {
                 $emails[] = Piwik::getSuperUserEmail();
             } else {
                 try {
                     $user = APIUsersManager::getInstance()->getUser($report['login']);
                 } catch (Exception $e) {
                     return;
                 }
                 $emails[] = $user['email'];
             }
         }
         foreach ($emails as $email) {
             if (empty($email)) {
                 continue;
             }
             $mail->addTo($email);
             try {
                 $mail->send();
             } catch (Exception $e) {
                 // If running from piwik.php with debug, we ignore the 'email not sent' error
                 if (!isset($GLOBALS['PIWIK_TRACKER_DEBUG']) || !$GLOBALS['PIWIK_TRACKER_DEBUG']) {
                     throw new Exception("An error occured while sending '{$filename}' " . " to " . implode(', ', $mail->getRecipients()) . ". Error was '" . $e->getMessage() . "'");
                 }
             }
             $mail->clearRecipients();
         }
     }
 }
 public function sendBug()
 {
     Piwik::checkUserHasSomeAdminAccess();
     $idSite = Common::getRequestVar('idSite', null, 'int');
     $email = Common::getRequestVar('email', null);
     $name = Common::getRequestVar('name', null);
     $website = Common::getRequestVar('website', null);
     $message = Common::getRequestVar('message', null);
     $jsonConfig = json_decode(file_get_contents(getcwd() . '/plugins/Chat/plugin.json'), true);
     if ($idSite != null && $email != null && $name != null && $website != null && $message != null) {
         $mail = new Mail();
         $mail->setFrom($email != null ? $email : Piwik::getCurrentUserEmail(), $name != null ? $name : Piwik::getCurrentUserLogin());
         $mail->setSubject("Bug report");
         $mail->setBodyHtml("Piwik Version : " . Version::VERSION . "<br />\n            Chat Version : " . $jsonConfig['version'] . "<br />\n            Website : " . $website . "<br /><br /><br />\n            Message:<br />" . $message);
         $mail->addTo($jsonConfig['authors'][0]['email']);
         try {
             $mail->send();
         } catch (Exception $e) {
             throw new Exception("An error occured while sending 'Bug Report' to " . implode(', ', $mail->getRecipients()) . " Error was '" . $e->getMessage() . "'");
         }
         return true;
     }
 }
 /**
  * send email to Piwik team and display nice thanks
  * @throws Exception
  */
 function sendFeedback()
 {
     $email = Common::getRequestVar('email', '', 'string');
     $body = Common::getRequestVar('body', '', 'string');
     $category = Common::getRequestVar('category', '', 'string');
     $nonce = Common::getRequestVar('nonce', '', 'string');
     $view = new View('@Feedback/sendFeedback');
     $view->feedbackEmailAddress = Config::getInstance()->General['feedback_email_address'];
     try {
         $minimumBodyLength = 40;
         if (strlen($body) < $minimumBodyLength || strpos($email, 'probe@') !== false || strpos($body, '&lt;probe') !== false) {
             throw new Exception(Piwik::translate('Feedback_ExceptionBodyLength', array($minimumBodyLength)));
         }
         if (!Piwik::isValidEmailString($email)) {
             throw new Exception(Piwik::translate('UsersManager_ExceptionInvalidEmail'));
         }
         if (preg_match('/https?:/i', $body)) {
             throw new Exception(Piwik::translate('Feedback_ExceptionNoUrls'));
         }
         if (!Nonce::verifyNonce('Feedback.sendFeedback', $nonce)) {
             throw new Exception(Piwik::translate('General_ExceptionNonceMismatch'));
         }
         Nonce::discardNonce('Feedback.sendFeedback');
         $mail = new Mail();
         $mail->setFrom(Common::unsanitizeInputValue($email));
         $mail->addTo($view->feedbackEmailAddress, 'Piwik Team');
         $mail->setSubject('[ Feedback form - Piwik ] ' . $category);
         $mail->setBodyText(Common::unsanitizeInputValue($body) . "\n" . 'Piwik ' . Version::VERSION . "\n" . 'IP: ' . IP::getIpFromHeader() . "\n" . 'URL: ' . Url::getReferrer() . "\n");
         @$mail->send();
     } catch (Exception $e) {
         $view->errorString = $e->getMessage();
         $view->message = $body;
     }
     return $view->render();
 }