Exemple #1
0
 private function sendDiagnosticEmail()
 {
     // generate tarball with logs
     //        $smtpServer = sfConfig::get("app_remote_log_smtpserver");
     $filepath = sfConfig::get("app_remote_log_file");
     $scriptfile = sfConfig::get("app_remote_log_mailscript");
     $email = sfConfig::get("app_remote_log_toemail");
     $security_type = EtvaSettingPeer::retrieveByParam(EtvaSettingPeer::_SMTP_SECURITY_)->getValue();
     $smtpServer = EtvaSettingPeer::retrieveByParam(EtvaSettingPeer::_SMTP_SERVER_)->getValue();
     $port = EtvaSettingPeer::retrieveByParam(EtvaSettingPeer::_SMTP_PORT_)->getValue();
     $useauth = EtvaSettingPeer::retrieveByParam(EtvaSettingPeer::_SMTP_USE_AUTH_)->getValue();
     if ($useauth == '1') {
         $username = EtvaSettingPeer::retrieveByParam(EtvaSettingPeer::_SMTP_USERNAME_)->getValue();
         $key = EtvaSettingPeer::retrieveByParam(EtvaSettingPeer::_SMTP_KEY_)->getValue();
     }
     error_log("[SMTPSERVER] {$smtpServer}");
     error_log("[COMMAND] perl {$scriptfile} {$filepath} {$smtpServer} {$port} {$email} {$security_type} {$useauth} {$username} {$key}");
     $command = "perl {$scriptfile} {$filepath} {$smtpServer} {$port} {$email} {$security_type} {$useauth} {$username} {$key}";
     $path = sfConfig::get('sf_root_dir') . DIRECTORY_SEPARATOR . "utils";
     ob_start();
     passthru('echo ' . $command . ' | sudo /usr/bin/php -f ' . $path . DIRECTORY_SEPARATOR . 'sudoexec.php', $retval);
     $content_grabbed = ob_get_contents();
     ob_end_clean();
     //exec($command, $output, $retval);
     //$output = shell_exec("perl $scriptfile $email $smtpServer $filepath");
     //error_log(print_r($output, true));
     if ($retval == 0) {
         //         $msg = array('success'=>true);
         //           return $this->renderText(json_encode($msg));
         return true;
     } else {
         //            $msg = "Cannot send email: \n";
         //            $msg .= implode("\n", $output);
         error_log("[ERROR] Couldn't send diagnostic by email" . print_r($content_grabbed, true));
         //            $info = array('success'=>false,'error'=>$msg, 'info'=>$msg);
         //            $error = $this->setJsonError($info);
         //            return $this->renderText($error);
         return false;
     }
 }