opensmtpdadmin/sendmail.php
2022-09-06 11:56:05 +00:00

63 lines
1.4 KiB
PHP

<?php
//
// OpenSMTPD Admin
// by Mischa Peters <mischa at high5 dot nl>
// Copyright (c) 2022 High5!
// License Info: LICENSE.TXT
//
// File: sendmail.php
//
// Template File: sendmail.tpl
//
// Template Variables:
//
// message
// from
// subject
// body
//
// POST / GET Variables:
//
// to
// subject
// body
//
require_once './functions.inc.php';
include './languages/' . check_language() . '.lang';
$SESSID_USERNAME = check_session();
$ROLE = check_role($SESSID_USERNAME);
if ($ROLE == ADMIN_ROLE) {
$list_domains = list_domains();
$list_admins = list_admins();
} else {
$list_domains = list_domains($SESSID_USERNAME);
}
if ($_SERVER['REQUEST_METHOD'] == "POST") {
$to = strtolower(filter_input(INPUT_POST, 'to', FILTER_VALIDATE_EMAIL));
$subject = filter_input(INPUT_POST, 'subject', FILTER_DEFAULT);
$body = filter_input(INPUT_POST, 'body', FILTER_DEFAULT);
$headers = "From: " . $SESSID_USERNAME . "\r\n";
$headers .= "Content-Type: text/plain; charset=utf-8\r\n";
if (empty($to)) {
$message = $LANG['Sendmail_to_text_error'];
}
if (empty($message)) {
if (!mail($to, $subject, $body, $headers)) {
$message = $LANG['Sendmail_result_error'];
} else {
$message = $LANG['Sendmail_result_succes'];
}
}
}
include './templates/header.tpl';
include './templates/menu.tpl';
include './templates/sendmail.tpl';
include './templates/footer.tpl';
?>