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.

90 lines
2.1 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.tpl
  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. mb_internal_encoding("UTF-8");
  43. $fHeaders .= "Subject: " . mb_encode_mimeheader( safepost('fSubject'), 'UTF-8', 'Q') . "\n";
  44. $fHeaders .= "MIME-Version: 1.0\n";
  45. $fHeaders .= "Content-Type: text/plain; charset=utf-8\n";
  46. $fHeaders .= "Content-Transfer-Encoding: 8bit\n";
  47. $fHeaders .= "\n";
  48. $tBody = $_POST['fBody'];
  49. if (get_magic_quotes_gpc ())
  50. {
  51. $tBody = stripslashes($tBody);
  52. }
  53. $fHeaders .= $tBody;
  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. $tMessage = $PALANG['pSendmail_to_text_error'];
  60. }
  61. if ($error != 1)
  62. {
  63. if (!smtp_mail ($fTo, $fFrom, $fHeaders))
  64. {
  65. $tMessage .= $PALANG['pSendmail_result_error'];
  66. }
  67. else
  68. {
  69. $tMessage .= $PALANG['pSendmail_result_success'];
  70. }
  71. }
  72. }
  73. $smarty->assign ('SESSID_USERNAME', $SESSID_USERNAME);
  74. $smarty->assign ('tMessage', $tMessage, false);
  75. $smarty->assign ('smarty_template', 'sendmail');
  76. $smarty->display ('index.tpl');
  77. /* vim: set expandtab softtabstop=3 tabstop=3 shiftwidth=3: */
  78. ?>