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.

83 lines
1.9 KiB

  1. <?php
  2. /**
  3. * Postfix Admin
  4. *
  5. * LICENSE
  6. * This source file is subject to the GPL license that is bundled with
  7. * this package in the file LICENSE.TXT.
  8. *
  9. * Further details on the project are available at :
  10. * http://www.postfixadmin.com or http://postfixadmin.sf.net
  11. *
  12. * @version $Id$
  13. * @license GNU GPL v2 or later.
  14. *
  15. * File: sendmail.php
  16. * Used to send an email to a user.
  17. * Template File: sendmail.php
  18. *
  19. * Template Variables:
  20. *
  21. * tMessage
  22. * tFrom
  23. * tSubject
  24. * tBody
  25. *
  26. * Form POST \ GET Variables:
  27. *
  28. * fTo
  29. * fSubject
  30. * fBody
  31. */
  32. require_once('common.php');
  33. authentication_require_role('admin');
  34. (($CONF['sendmail'] == 'NO') ? header("Location: " . $CONF['postfix_admin_url'] . "/main.php") && exit : '1');
  35. $SESSID_USERNAME = authentication_get_username();
  36. if ($_SERVER['REQUEST_METHOD'] == "POST")
  37. {
  38. $fTo = safepost('fTo');
  39. $fFrom = $SESSID_USERNAME;
  40. $fHeaders = "To: " . $fTo . "\n";
  41. $fHeaders .= "From: " . $fFrom . "\n";
  42. $fHeaders .= "Subject: " . encode_header(safepost('fSubject')) . "\n";
  43. $fHeaders .= "MIME-Version: 1.0\n";
  44. $fHeaders .= "Content-Type: text/plain; charset=utf-8\n";
  45. $fHeaders .= "Content-Transfer-Encoding: 8bit\n";
  46. $fHeaders .= escape_string ($_POST['fBody']);
  47. if (empty ($fTo) or !check_email ($fTo))
  48. {
  49. $error = 1;
  50. $tTo = escape_string ($_POST['fTo']);
  51. $tSubject = escape_string ($_POST['fSubject']);
  52. $tBody = escape_string ($_POST['fBody']);
  53. $tMessage = $PALANG['pSendmail_to_text_error'];
  54. }
  55. if ($error != 1)
  56. {
  57. if (!smtp_mail ($fTo, $fFrom, $fHeaders))
  58. {
  59. $tMessage .= $PALANG['pSendmail_result_error'];
  60. }
  61. else
  62. {
  63. $tMessage .= $PALANG['pSendmail_result_success'];
  64. }
  65. }
  66. }
  67. include ("./templates/header.php");
  68. include ("./templates/menu.php");
  69. include ("./templates/sendmail.php");
  70. include ("./templates/footer.php");
  71. /* vim: set expandtab softtabstop=3 tabstop=3 shiftwidth=3: */
  72. ?>