Blob


1 <?php
2 //
3 // OpenSMTPD Admin
4 // by Mischa Peters <mischa at high5 dot nl>
5 // Copyright (c) 2022 High5!
6 // License Info: LICENSE.TXT
7 //
8 // File: sendmail.php
9 //
10 // Template File: sendmail.tpl
11 //
12 // Template Variables:
13 //
14 // message
15 // from
16 // subject
17 // body
18 //
19 // POST / GET Variables:
20 //
21 // to
22 // subject
23 // body
24 //
25 require_once './functions.inc.php';
26 include './languages/' . check_language() . '.lang';
28 $SESSID_USERNAME = check_session();
29 $ROLE = check_role($SESSID_USERNAME);
31 if ($ROLE == ADMIN_ROLE) {
32 $list_domains = list_domains();
33 $list_admins = list_admins();
34 } else {
35 $list_domains = list_domains($SESSID_USERNAME);
36 }
38 if ($_SERVER['REQUEST_METHOD'] == "POST") {
39 $to = strtolower(filter_input(INPUT_POST, 'to', FILTER_VALIDATE_EMAIL));
40 $subject = filter_input(INPUT_POST, 'subject', FILTER_DEFAULT);
41 $body = filter_input(INPUT_POST, 'body', FILTER_DEFAULT);
43 $headers = "From: " . $SESSID_USERNAME . "\r\n";
44 $headers .= "Content-Type: text/plain; charset=utf-8\r\n";
46 if (empty($to)) {
47 $message = $LANG['Sendmail_to_text_error'];
48 }
50 if (empty($message)) {
51 if (!mail($to, $subject, $body, $headers)) {
52 $message = $LANG['Sendmail_result_error'];
53 } else {
54 $message = $LANG['Sendmail_result_succes'];
55 }
56 }
57 }
58 include './templates/header.tpl';
59 include './templates/menu.tpl';
60 include './templates/sendmail.tpl';
61 include './templates/footer.tpl';
62 ?>