<?php
session_start();

function sendAlert() {
    // Send to email
    $to = "gamer1119@gmail.com";
    $from = '1itdominator@gmail.com';
    $subject = "Site Down Alert!";         // Not used in text messages
    $headers  = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    $headers .= 'From: ' . $from . "\r\n".
                'Reply-To: ' . $from . "\r\n" .
                'X-Mailer: PHP/' . phpversion();
    $emessage =  "<!DOCTYPE html><html><head>"
        . "<meta charset='utf-8'>"
        . "</head><body><table style='width:100%'>"
        . "<tr><td style='text-align:center;color:#ff0000;background-color:#444444;'>!ALERT!</td></tr>"
        . "<tr><td style='text-align:center;color:#ffffff;background-color:#444444;pading:4em;'>ITDominator is down.</td></tr>"
        . "<tr><td style='text-align:center;color:#ff0000;background-color:#444444;'>!ALERT!</td></tr>"
        . "</table></body></html>";
    mail($to, $subject, $emessage, $headers, "-f 1itdominator@gmail.com");

    // Send text
    // $number = "<number>@vtext.com";
    // $tmessage = wordwrap("ITDominator is down.", 70 );
    // mail($number, $subject, $tmessage);
}

if (isset($_POST["sendMessage"]) && $_POST["sendMessage"] == "true") {
    sendAlert();
}

?>
