Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

sendmail.php 1.9KB

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$
  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. if (safepost('token') != $_SESSION['PFA_token']) {
  36. die('Invalid token!');
  37. }
  38. $fTo = safepost('fTo');
  39. $fFrom = $smtp_from_email;
  40. $fSubject = safepost('fSubject');
  41. $tBody = $_POST['fBody'];
  42. if (get_magic_quotes_gpc()) {
  43. $tBody = stripslashes($tBody); # TODO: check for get_magic_quotes_gpc inside safepost/safeget
  44. }
  45. $error = 0;
  46. $email_check = check_email($fTo);
  47. if (empty($fTo) or ($email_check != '')) {
  48. $error = 1;
  49. $tTo = escape_string($_POST['fTo']);
  50. $tSubject = escape_string($_POST['fSubject']);
  51. flash_error($PALANG['pSendmail_to_text_error']); # TODO: superfluous?
  52. flash_error($email_check);
  53. }
  54. if ($error != 1) {
  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: */