PostfixAdmin - web based virtual user administration interface for Postfix mail servers https://postfixadmin.github.io/postfixadmin/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

88 lines
2.2 KiB

  1. <?php
  2. //
  3. // Postfix Admin
  4. // by Mischa Peters <mischa at high5 dot net>
  5. // Copyright (c) 2002 - 2005 High5!
  6. // Licensed under GPL for more info check GPL-LICENSE.TXT
  7. //
  8. // File: sendmail.php
  9. //
  10. // Template File: sendmail.tpl
  11. //
  12. // Template Variables:
  13. //
  14. // tMessage
  15. // tFrom
  16. // tSubject
  17. // tBody
  18. //
  19. // Form POST \ GET Variables:
  20. //
  21. // fTo
  22. // fSubject
  23. // fBody
  24. //
  25. require_once('common.php');
  26. authentication_require_role('admin');
  27. (($CONF['sendmail'] == 'NO') ? header("Location: " . $CONF['postfix_admin_url'] . "/main.php") && exit : '1');
  28. $SESSID_USERNAME = authentication_get_username();
  29. if ($_SERVER['REQUEST_METHOD'] == "GET")
  30. {
  31. include ("./templates/header.tpl");
  32. include ("./templates/menu.tpl");
  33. include ("./templates/sendmail.tpl");
  34. include ("./templates/footer.tpl");
  35. }
  36. if ($_SERVER['REQUEST_METHOD'] == "POST")
  37. {
  38. if (isset ($_POST['fTo'])) $fTo = escape_string ($_POST['fTo']);
  39. $fFrom = $SESSID_USERNAME;
  40. if (isset ($_POST['fTo'])) $fHeaders = "To: " . $fTo . "\n";
  41. if (isset ($_POST['fTo'])) $fHeaders .= "From: " . $fFrom . "\n";
  42. if (!empty ($PALANG['charset']))
  43. {
  44. $fHeaders .= "Subject: " . encode_header (escape_string ($_POST['fSubject']), $PALANG['charset']) . "\n";
  45. $fHeaders .= "MIME-Version: 1.0\n";
  46. $fHeaders .= "Content-Type: text/plain; charset=" . $PALANG['charset'] . "\n";
  47. $fHeaders .= "Content-Transfer-Encoding: 8bit\n";
  48. }
  49. else
  50. {
  51. $fHeaders .= "Subject: " . escape_string ($_POST['fSubject']) . "\n\n";
  52. }
  53. $fHeaders .= escape_string ($_POST['fBody']);
  54. if (empty ($fTo) or !check_email ($fTo))
  55. {
  56. $error = 1;
  57. $tTo = escape_string ($_POST['fTo']);
  58. $tSubject = escape_string ($_POST['fSubject']);
  59. $tBody = escape_string ($_POST['fBody']);
  60. $tMessage = $PALANG['pSendmail_to_text_error'];
  61. }
  62. if ($error != 1)
  63. {
  64. if (!smtp_mail ($fTo, $fFrom, $fHeaders))
  65. {
  66. $tMessage .= $PALANG['pSendmail_result_error'];
  67. }
  68. else
  69. {
  70. $tMessage .= $PALANG['pSendmail_result_success'];
  71. }
  72. }
  73. include ("./templates/header.tpl");
  74. include ("./templates/menu.tpl");
  75. include ("./templates/sendmail.tpl");
  76. include ("./templates/footer.tpl");
  77. }
  78. ?>