sendmail.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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 http://postfixadmin.sf.net
  10. *
  11. * @version $Id: sendmail.php 1781 2015-04-06 22:44:51Z christian_boltz $
  12. * @license GNU GPL v2 or later.
  13. *
  14. * File: sendmail.php
  15. * Used to send an email to a user.
  16. * Template File: sendmail.tpl
  17. *
  18. * Template Variables:
  19. *
  20. * tFrom
  21. * tSubject
  22. * tBody
  23. *
  24. * Form POST \ GET Variables:
  25. *
  26. * fTo
  27. * fSubject
  28. * fBody
  29. */
  30. require_once('common.php');
  31. authentication_require_role('admin');
  32. (($CONF['sendmail'] == 'NO') ? header("Location: main.php") && exit : '1');
  33. $smtp_from_email = smtp_get_admin_email();
  34. if ($_SERVER['REQUEST_METHOD'] == "POST")
  35. {
  36. $fTo = safepost('fTo');
  37. $fFrom = $smtp_from_email;
  38. $fSubject = safepost('fSubject');
  39. $tBody = $_POST['fBody'];
  40. if (get_magic_quotes_gpc ())
  41. {
  42. $tBody = stripslashes($tBody); # TODO: check for get_magic_quotes_gpc inside safepost/safeget
  43. }
  44. $email_check = check_email ($fTo);
  45. if (empty ($fTo) or ($email_check != ''))
  46. {
  47. $error = 1;
  48. $tTo = escape_string ($_POST['fTo']);
  49. $tSubject = escape_string ($_POST['fSubject']);
  50. flash_error($PALANG['pSendmail_to_text_error']); # TODO: superfluous?
  51. flash_error($email_check);
  52. }
  53. if ($error != 1)
  54. {
  55. if (!smtp_mail ($fTo, $fFrom, $fSubject, $tBody)) {
  56. flash_error(Config::lang_f('pSendmail_result_error', $fTo));
  57. } else {
  58. flash_info(Config::lang_f('pSendmail_result_success', $fTo));
  59. }
  60. }
  61. }
  62. $smarty->assign ('smtp_from_email', $smtp_from_email);
  63. $smarty->assign ('smarty_template', 'sendmail');
  64. $smarty->display ('index.tpl');
  65. /* vim: set expandtab softtabstop=3 tabstop=3 shiftwidth=3: */
  66. ?>