mail-wrapper.php 1010 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. #!/usr/local/vesta/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/vesta/web/inc/main.php");
  15. // Set system language
  16. exec (VESTA_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';
  22. }
  23. require_once('/usr/local/vesta/web/inc/i18n/'.$_SESSION['language'].'.php');
  24. // Define vars
  25. $from = 'Vesta Control Panel <vesta@'.gethostname().'>';
  26. $to = $argv[3]."\n";
  27. $subject = $argv[2]."\n";
  28. $mailtext = file_get_contents("php://stdin");
  29. // Send email
  30. if ((!empty($to)) && (!empty($subject))) {
  31. send_email($to,$subject,$mailtext,$from);
  32. }