mail-wrapper.php 1017 B

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