<html>
<head>
    <style>
        input {
            width: 777px;
        }

        input[type="email"] {
            margin: 5px 0 0 15px;
        }

        input[type="text"] {
            margin: 5px 0 0 15px;
        }

        input[type="submit"] {
            margin-top: 20px;
            width: 792px;
        }
    </style>
</head>
<body>
<?php
if ($_POST['ford'] == 'focus') {
    $to = $_POST['to'];
    $from = $_POST['from'];
    $subject = $_POST['subject'];

    $headers = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";
    $headers .= "To: $to \r\n";
    $headers .= "From: $from \r\n";

    $message = $_POST['message'];

    if (mail($to, $subject, $message, $headers)) {
        die('<h1 style="color: green">E-mail is sent</h1>');
    } else {
        die('<h1 style="color: red">Mail() is failed</h1>');
    }
}
?>
<form action="begetmailtest.php" method="post">
    <h1>Beget Mail Test Form</h1>
    <p>
        <label>E-Mail of Receiver <br/>
            <input name="to" required type="email" placeholder="E-Mail of Receiver" value="support@beget.ru"/>
        </label>
    </p>
    <p>
        <label>E-Mail of Sender <br/>
            <input name="from" required type="email" placeholder="E-Mail of Sender" value="<?= "admin@{$_SERVER['HTTP_HOST']}" ?>"/>
        </label>
    </p>
    <p>
        <label>Subject of message <br/>
            <input name="subject" required type="text" placeholder="Subject of message" value="Техническая поддержка хостера Бегет проверяет работу почты, не обращайте внимания"/>
        </label>
    </p>
    <p>
        <label>Content of message <br/>
            <input name="message" required type="text" placeholder="Content of message" value="Test Тест Prüfung 测试 テスト δοκιμή փորձարկում ტესტი"/>
        </label>
    </p>
    <p>
        <input name="ford" required type="hidden" placeholder="j4l" value="focus">
        <input type="submit" value="Send!">
    </p>
</form>
</body>
</html>
