<?php

    define("DEMO",true);

    //Create a template for sending email
    $templateFile = "./template.php";
    $templateFile2 = "./email_templates/template-email-activation.php";

    //add basic email info to send
    $email_to = "some@gmail.com";
    $subject = "Simple email with php";
    
    $swap_var = array(
        "{SITE_ADDR}" => "",
        "{EMAIL_LOGO}" => "",
        "{EMAIL_TITLE}" => "",
        "{CUSTOM_URL}" => "",
        "{CUSTOM_IMG}" => "",
        "{TO_NAME}" => "",
        "{TO_EMAIL}" => ""
    );

    //create email headers
    $headers = "From: TEAM GEESE <teamgeese1@gmail.com> \r\n";
    $headers .= "MIME-Version: 1.0 \r\n";
    $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";

    //create an html message to be sent
    // $message = "<html>
    
    // <body> 
    
    //     <h1 style='background-color:red; font-size: 30px;'>Checkout this H1 Tag</h1>
    //     <p style='padding:10px; margin-top: 20px;'>With <i>Paragraphs</i></p>
    //     <h2>Checkout this H1 Tag</h2>
    //     <p>With Paragraphs</p>
    
    // </body>

    // </html>";
 
    if(file_exists($templateFile)){
        $message = file_get_contents($templateFile);
    }else{
        die("unable to locate the template file");
    }

    //Now replace all the search swap var 
    foreach(array_keys($swap_var) as $key){
        if(strlen($key)>2 && trim($key) != ""){
            $message = str_replace($key, $swap_var[$key], $message);
        }
    }

    if(DEMO){
        die("<hr/>no email was sent on purpose!!");
    }

    //display the email message to the user
    echo $message;


    //send email to the user
    if(mail($email_to, $subject, $message, $headers)){
        echo "<hr/>Success";
    }else{
        echo "<hr/>Not-Sent";
    }


?>