File: sendmail.php

package info (click to toggle)
postfixadmin 3.3.15%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 3,816 kB
  • sloc: php: 10,120; perl: 1,069; sh: 643; python: 169; xml: 62; sql: 3; makefile: 2
file content (78 lines) | stat: -rw-r--r-- 1,898 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?php
/**
 * Postfix Admin
 *
 * LICENSE
 * This source file is subject to the GPL license that is bundled with
 * this package in the file LICENSE.TXT.
 *
 * Further details on the project are available at http://postfixadmin.sf.net
 *
 * @version $Id$
 * @license GNU GPL v2 or later.
 *
 * File: sendmail.php
 * Used to send an email to a user.
 * Template File: sendmail.tpl
 *
 * Template Variables:
 *
 * tFrom
 * tSubject
 * tBody
 *
 * Form POST \ GET Variables:
 *
 * fTo
 * fSubject
 * fBody
 */

require_once('common.php');

authentication_require_role('admin');

$CONF = Config::getInstance()->getAll();
$smarty = PFASmarty::getInstance();
$PALANG = $CONF['__LANG'];

(($CONF['sendmail'] == 'NO') ? header("Location: main.php") && exit : '1');

$smtp_from_email = smtp_get_admin_email();


if ($_SERVER['REQUEST_METHOD'] == "POST") {
    if (safepost('token') != $_SESSION['PFA_token']) {
        die('Invalid token!');
    }

    $fTo = safepost('fTo');
    $fFrom = $smtp_from_email;
    $fSubject = safepost('fSubject');

    $tBody = $_POST['fBody'];

    $error = 0;
    $email_check = check_email($fTo);
    if (empty($fTo) or ($email_check != '')) {
        $error = 1;
        $tTo = escape_string($_POST['fTo']);
        $tSubject = escape_string($_POST['fSubject']);
        flash_error($PALANG['pSendmail_to_text_error']); # TODO: superfluous?
        flash_error($email_check);
    }

    if ($error != 1) {
        if (!smtp_mail($fTo, $fFrom, $fSubject, smtp_get_admin_password(), $tBody)) {
            flash_error(Config::lang_f('pSendmail_result_error', $fTo));
        } else {
            flash_info(Config::lang_f('pSendmail_result_success', $fTo));
        }
    }
}
$smarty->assign('smtp_from_email', $smtp_from_email);
$smarty->assign('smarty_template', 'sendmail');
$smarty->display('index.tpl');


/* vim: set expandtab softtabstop=3 tabstop=3 shiftwidth=3: */