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 31require_once('common.php'); 32 33authentication_require_role('admin'); 34 35$CONF = Config::getInstance()->getAll(); 36$smarty = PFASmarty::getInstance(); 37$PALANG = $CONF['__LANG']; 38 39(($CONF['sendmail'] == 'NO') ? header("Location: main.php") && exit : '1'); 40 41$smtp_from_email = smtp_get_admin_email(); 42 43 44if ($_SERVER['REQUEST_METHOD'] == "POST") { 45 if (safepost('token') != $_SESSION['PFA_token']) { 46 die('Invalid token!'); 47 } 48 49 $fTo = safepost('fTo'); 50 $fFrom = $smtp_from_email; 51 $fSubject = safepost('fSubject'); 52 53 $tBody = $_POST['fBody']; 54 55 $error = 0; 56 $email_check = check_email($fTo); 57 if (empty($fTo) or ($email_check != '')) { 58 $error = 1; 59 $tTo = escape_string($_POST['fTo']); 60 $tSubject = escape_string($_POST['fSubject']); 61 flash_error($PALANG['pSendmail_to_text_error']); # TODO: superfluous? 62 flash_error($email_check); 63 } 64 65 if ($error != 1) { 66 if (!smtp_mail($fTo, $fFrom, $fSubject, smtp_get_admin_password(), $tBody)) { 67 flash_error(Config::lang_f('pSendmail_result_error', $fTo)); 68 } else { 69 flash_info(Config::lang_f('pSendmail_result_success', $fTo)); 70 } 71 } 72} 73$smarty->assign('smtp_from_email', $smtp_from_email); 74$smarty->assign('smarty_template', 'sendmail'); 75$smarty->display('index.tpl'); 76 77 78/* vim: set expandtab softtabstop=3 tabstop=3 shiftwidth=3: */ 79