<?php 

    //We need to download the PHPMailer file from github

    if(isset($_POST["submit"])){
        
        $name = $_POST["name"];

        require 'phpmailer/PHPMailerAutoload.php';
        //The client email id and password will be stored in the file below:
        require 'credential.php';

        $mail = new PHPMailer;
        $mail->SMTPDebug = 4;

        $mail->isSMTP();
        $mail->Host = 'smtp.gmail.com';

        $mail->SMTPAuth = true;
        //This value of EMAIL and PASSWORD is stored in credential.php
        $mail->Username = EMAIL;
        $mail->Password = PASSWORD;

        $mail->SMTPSecure = 'tls';
        $mail->Port = 587;

        //The $name is the name of the person who has provided the feedback
        //The setFrom is the account which is used to send the mail via
        $mail->setFrom(EMAIL, $name);
        //The addAddress is the account to which the mail is send
        $mail->addAddress($_POST["email"]);
        $mail->addReplyTo(EMAIL);

        $mail->isHTML(true);

        //This is one send to the user who has submitted the feedback;
        $mail->Subject = "Here is the Subject";
        $mail->Body = "This is HTML message of the body <b>in bold</b>";
        //THis is send in case the HTML message cannot be sent
        $mail->AltBody = "This is the plain text body in non-html";

        if(!$mail->send()){
            echo "Message couldn't be send.";
            echo "Mailer Error: " . $mail->ErrorInfo;
        }else{
            echo "Message has been sent";
        }

    }

?>