mail-wrapper.php 941 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. #!/usr/local/hestia/php/bin/php
  2. <?php
  3. error_reporting(NULL);
  4. if (empty($argv[1])) {
  5. echo "ERROR: not enough arguments\n";
  6. echo "USAGE: mail-wrapper.php -s SUBJECT EMAIL [NOTIFY]\n";
  7. exit(3);
  8. }
  9. $options = getopt("s:f:");
  10. if ((!empty($argv[4])) && ($argv[4] == 'no')) {
  11. exit;
  12. }
  13. define('NO_AUTH_REQUIRED',true);
  14. include("/usr/local/hestia/web/inc/main.php");
  15. // Set system language
  16. exec (HESTIA_CMD . "v-list-sys-config json", $output, $return_var);
  17. $data = json_decode(implode('', $output), true);
  18. if (!empty( $data['config']['LANGUAGE'])) {
  19. $_SESSION['language'] = $data['config']['LANGUAGE'];
  20. } else {
  21. $_SESSION['language'] = 'en_US';
  22. }
  23. // Define vars
  24. $from = 'Hestia Control Panel <hestia@'.gethostname().'>';
  25. $to = $argv[3]."\n";
  26. $subject = $argv[2]."\n";
  27. $mailtext = file_get_contents("php://stdin");
  28. // Send email
  29. if ((!empty($to)) && (!empty($subject))) {
  30. send_email($to,$subject,$mailtext,$from);
  31. }