<?php
 
date_default_timezone_set('Asia/Kolkata');
$time = date('Y-m-d H:i:s');

if(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on') $url = "https://"; 
else $url = "http://";
$url.= $_SERVER['HTTP_HOST'];
$url.= $_SERVER['REQUEST_URI'];
$officialEmail = $_GET['officialEmail'];
$fullName = $_GET['fullName'];

require "./vendor/autoload.php";

use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;

$mailer = new PHPMailer(true);

try {
    $mailer->SMTPDebug = 0;
    $mailer->isSMTP();

    $mailer->SMTPOptions = [
        'ssl' => [
            'verify_peer' => false,
            'verify_peer_name' => false,
            'allow_self_signed' => true,
        ]
    ];

    $mailer->Host = 'mail.gainskillsmedia.com';
    $mailer->SMTPAuth = true;
    $mailer->Username = 'info@gainskillsmedia.com';
    $mailer->Password = 'Info@122022';
    $mailer->SMTPSecure = "tls";
    $mailer->SMTPAutoTLS = false;
    $mailer->Port = 587;

    $mailer->setFrom('info@gainskillsmedia.com', 'Gainskills Business Media');
    $mailer->addAddress("$officialEmail", "$fullName");
    // $mailer->addAddress('sumeetk@gainskillsmedia.com', 'Sumeet Khatri');
    // $mailer->addCC('Adil@gainskillsmedia.com', 'Adil Z Najeeb');

    $mailer->isHTML(true);
    $mailer->Subject = "Your Form has been Submitted - Gain Skills ";
    $mailer->Body = "
        <!doctype html>
        <html data-css-strict>
        <head><meta charset='utf-8'><style></style>
            <style amp-custom>
                u ~ div img + div > div {
                	display:none;
                }
                span.MsoHyperlink, span.MsoHyperlinkFollowed {
                	color:inherit;
                }
                a.es-button {
                	text-decoration:none;
                }
                .es-desk-hidden {
                	display:none;
                	float:left;
                	overflow:hidden;
                	width:0;
                	max-height:0;
                	line-height:0;
                }
                .es-header-body a:hover {
                	color:#2CB543;
                }
                .es-content-body a:hover {
                	color:#2CB543;
                }
                .es-footer-body a:hover {
                	color:#FFFFFF;
                }
                .es-infoblock a:hover {
                	color:#CCCCCC;
                }
                .es-button-border:hover > a.es-button {
                	color:#FFFFFF;
                }
                body {
                	width:100%;
                	height:100%;
                }
                table {
                	border-collapse:collapse;
                	border-spacing:0px;
                }
                table td, body, .es-wrapper {
                	padding:0;
                	Margin:0;
                }
                .es-content, .es-header, .es-footer {
                	width:100%;
                	table-layout:fixed;
                }
                p, hr {
                	Margin:0;
                }
                h1, h2, h3, h4, h5, h6 {
                	Margin:0;
                	font-family:arial, 'helvetica neue', helvetica, sans-serif;
                	letter-spacing:0;
                }
                .es-left {
                	float:left;
                }
                .es-right {
                	float:right;
                }
                .es-menu td {
                	border:0;
                }
                s {
                	text-decoration:line-through;
                }
                a {
                	text-decoration:underline;
                }
                .es-menu td a {
                	font-family:arial, 'helvetica neue', helvetica, sans-serif;
                	text-decoration:none;
                	display:block;
                }
                .es-menu amp-img, .es-button amp-img {
                	vertical-align:middle;
                }
                .es-wrapper {
                	width:100%;
                	height:100%;
                }
                .es-wrapper-color, .es-wrapper {
                	background-color:#F6F6F6;
                }
                .es-content-body p, .es-footer-body p, .es-header-body p, .es-infoblock p {
                	font-family:arial, 'helvetica neue', helvetica, sans-serif;
                	line-height:150%;
                	letter-spacing:0;
                }
                .es-header {
                	background-color:transparent;
                }
                .es-header-body {
                	background-color:#FFFFFF;
                }
                .es-header-body p {
                	color:#333333;
                	font-size:14px;
                }
                .es-header-body a {
                	color:#2CB543;
                	font-size:14px;
                }
                .es-footer {
                	background-color:transparent;
                }
                .es-footer-body {
                	background-color:#FFFFFF;
                }
                .es-footer-body p {
                	color:#333333;
                	font-size:14px;
                }
                .es-footer-body a {
                	color:#FFFFFF;
                	font-size:14px;
                }
                .es-content-body {
                	background-color:#FFFFFF;
                }
                .es-content-body p {
                	color:#333333;
                	font-size:14px;
                }
                .es-content-body a {
                	color:#2CB543;
                	font-size:14px;
                }
                .es-infoblock p {
                	font-size:12px;
                	color:#CCCCCC;
                }
                .es-infoblock a {
                	font-size:12px;
                	color:#CCCCCC;
                }
                h1 {
                	font-size:30px;
                	font-style:normal;
                	font-weight:normal;
                	line-height:120%;
                	color:#333333;
                }
                h2 {
                	font-size:24px;
                	font-style:normal;
                	font-weight:normal;
                	line-height:120%;
                	color:#333333;
                }
                h3 {
                	font-size:20px;
                	font-style:normal;
                	font-weight:normal;
                	line-height:120%;
                	color:#333333;
                }
                h4 {
                	font-size:24px;
                	font-style:normal;
                	font-weight:normal;
                	line-height:120%;
                	color:#333333;
                }
                h5 {
                	font-size:20px;
                	font-style:normal;
                	font-weight:normal;
                	line-height:120%;
                	color:#333333;
                }
                h6 {
                	font-size:16px;
                	font-style:normal;
                	font-weight:normal;
                	line-height:120%;
                	color:#333333;
                }
                .es-header-body h1 a, .es-content-body h1 a, .es-footer-body h1 a {
                	font-size:30px;
                }
                .es-header-body h2 a, .es-content-body h2 a, .es-footer-body h2 a {
                	font-size:24px;
                }
                .es-header-body h3 a, .es-content-body h3 a, .es-footer-body h3 a {
                	font-size:20px;
                }
                .es-header-body h4 a, .es-content-body h4 a, .es-footer-body h4 a {
                	font-size:24px;
                }
                .es-header-body h5 a, .es-content-body h5 a, .es-footer-body h5 a {
                	font-size:20px;
                }
                .es-header-body h6 a, .es-content-body h6 a, .es-footer-body h6 a {
                	font-size:16px;
                }
                a.es-button, button.es-button {
                	padding:10px 20px 10px 20px;
                	display:inline-block;
                	background:#31CB4B;
                	border-radius:30px 30px 30px 30px;
                	font-size:18px;
                	font-family:arial, 'helvetica neue', helvetica, sans-serif;
                	font-weight:normal;
                	font-style:normal;
                	line-height:120%;
                	color:#FFFFFF;
                	text-decoration:none;
                	width:auto;
                	text-align:center;
                	letter-spacing:0;
                }
                .es-button-border {
                	border-style:solid;
                	border-color:#2CB543 #2CB543 #2CB543 #2CB543;
                	background:#2CB543;
                	border-width:0px 0px 2px 0px;
                	display:inline-block;
                	border-radius:30px 30px 30px 30px;
                	width:auto;
                }
                .es-button img {
                	display:inline-block;
                	vertical-align:middle;
                }
                .es-fw, .es-fw .es-button {
                	display:block;
                }
                .es-il, .es-il .es-button {
                	display:inline-block;
                }
                .es-p20t {
                	padding-top:20px;
                }
                .es-p20r {
                	padding-right:20px;
                }
                .es-p20l {
                	padding-left:20px;
                }
                .es-p20b {
                	padding-bottom:20px;
                }
                @media only screen and (max-width:3000px) {.rollover-amp > div { font-size:0; margin-top:-1px; position:absolute } .rollover-amp:hover .rollover-first + div { position:relative } .rollover-amp:hover amp-img.rollover-first, .rollover-amp amp-img.rollover-first + div, .rollover-amp:hover amp-img.rollover-first *, .rollover-amp amp-img.rollover-first + div * { height:1px; width:1px; opacity:0 } .rollover-amp:hover amp-img.rollover-first { max-height:0 } .rollover-amp:hover amp-img.rollover-first + div, .rollover-amp amp-img.rollover-first + div * { width:100%; height:auto; opacity:1 } }
                @media only screen and (max-width:600px) {td.es-m-p0r { padding-right:0px } *[class='gmail-fix'] { display:none } p, a { line-height:150% } h1, h1 a { line-height:120% } h2, h2 a { line-height:120% } h3, h3 a { line-height:120% } h4, h4 a { line-height:120% } h5, h5 a { line-height:120% } h6, h6 a { line-height:120% } .es-header-body p { } .es-content-body p { } .es-footer-body p { } .es-infoblock p { } h1 { font-size:30px; text-align:left } h2 { font-size:24px; text-align:left } h3 { font-size:20px; text-align:left } h4 { font-size:24px; text-align:left } h5 { font-size:20px; text-align:left } h6 { font-size:16px; text-align:left } .es-header-body h1 a, .es-content-body h1 a, .es-footer-body h1 a { font-size:30px } .es-header-body h2 a, .es-content-body h2 a, .es-footer-body h2 a { font-size:24px } .es-header-body h3 a, .es-content-body h3 a, .es-footer-body h3 a { font-size:20px } .es-header-body h4 a, .es-content-body h4 a, .es-footer-body h4 a { font-size:24px } .es-header-body h5 a, .es-content-body h5 a, .es-footer-body h5 a { font-size:20px } .es-header-body h6 a, .es-content-body h6 a, .es-footer-body h6 a { font-size:16px } .es-menu td a { font-size:14px } .es-header-body p, .es-header-body a { font-size:14px } .es-content-body p, .es-content-body a { font-size:14px } .es-footer-body p, .es-footer-body a { font-size:14px } .es-infoblock p, .es-infoblock a { font-size:12px } .es-m-txt-c, .es-m-txt-c h1, .es-m-txt-c h2, .es-m-txt-c h3, .es-m-txt-c h4, .es-m-txt-c h5, .es-m-txt-c h6 { text-align:center } .es-m-txt-r, .es-m-txt-r h1, .es-m-txt-r h2, .es-m-txt-r h3, .es-m-txt-r h4, .es-m-txt-r h5, .es-m-txt-r h6 { text-align:right } .es-m-txt-j, .es-m-txt-j h1, .es-m-txt-j h2, .es-m-txt-j h3, .es-m-txt-j h4, .es-m-txt-j h5, .es-m-txt-j h6 { text-align:justify } .es-m-txt-l, .es-m-txt-l h1, .es-m-txt-l h2, .es-m-txt-l h3, .es-m-txt-l h4, .es-m-txt-l h5, .es-m-txt-l h6 { text-align:left } .es-m-txt-r img, .es-m-txt-c img, .es-m-txt-l img, .es-m-txt-r .rollover:hover .rollover-second, .es-m-txt-c .rollover:hover .rollover-second, .es-m-txt-l .rollover:hover .rollover-second { display:inline } .es-m-txt-r .rollover div, .es-m-txt-c .rollover div, .es-m-txt-l .rollover div { line-height:0; font-size:0 } .es-spacer { display:inline-table } a.es-button, button.es-button { font-size:18px } .es-m-fw, .es-m-fw.es-fw, .es-m-fw .es-button { display:block } .es-m-il, .es-m-il .es-button, .es-social, .es-social td, .es-menu { display:inline-block } .es-adaptive table, .es-left, .es-right { width:100% } .es-content table, .es-header table, .es-footer table, .es-content, .es-footer, .es-header { width:100%; max-width:600px } .adapt-img { width:100%; height:auto } .es-mobile-hidden, .es-hidden { display:none } .es-desk-hidden { width:auto; overflow:visible; float:none; max-height:inherit; line-height:inherit } tr.es-desk-hidden { display:table-row } table.es-desk-hidden { display:table } td.es-desk-menu-hidden { display:table-cell } .es-menu td { width:1% } table.es-table-not-adapt, .esd-block-html table { width:auto } .es-social td { padding-bottom:10px } .h-auto { height:auto } a.es-button, button.es-button { display:inline-block } .es-button-border { display:inline-block } }
            </style>
        </head>
        <body>
            <div class='es-wrapper-color'>
                <table class='es-wrapper' width='100%' cellspacing='0' cellpadding='0'>
                    <tr>
                        <td valign='top'>
                            <table class='es-header' cellspacing='0' cellpadding='0' align='center'>
                                <tr>
                                    <td align='center'>
                                        <table class='es-header-body' width='600' cellspacing='0' cellpadding='0' bgcolor='#ffffff' align='center'>
                                            <tr>
                                                <td class='es-p20t es-p20r es-p20l' align='left'>
                                                    <table cellspacing='0' cellpadding='0' width='100%'>
                                                        <tr>
                                                            <td class='es-m-p0r' width='560' valign='top' align='center'>
                                                                <table width='100%' cellspacing='0' cellpadding='0' role='presentation'>
                                                                    <tr>
                                                                        <td align='center'>
                                                                            <p style='font-size: 32px'><strong>Thanks for Connecting With Us!!!</strong></p>
                                                                        </td>
                                                                    </tr>
                                                                </table>
                                                            </td>
                                                        </tr>
                                                    </table>
                                                </td>
                                            </tr>
                                        </table>
                                    </td>
                                </tr>
                            </table>
                            <table class='es-content' cellspacing='0' cellpadding='0' align='center'>
                                <tr>
                                    <td align='center'>
                                        <table class='es-content-body' width='600' cellspacing='0' cellpadding='0' bgcolor='#ffffff' align='center'>
                                            <tr>
                                                <td class='es-p20t es-p20r es-p20l' align='left'>
                                                    <table width='100%' cellspacing='0' cellpadding='0'>
                                                        <tr>
                                                            <td width='560' valign='top' align='center'>
                                                                <table width='100%' cellspacing='0' cellpadding='0' role='presentation'>
                                                                    <tr>
                                                                        <td align='center'>
                                                                            <img src='https://gainskillsmedia.com/assets/images/successmail.webp' alt='image' style='margin:30px 0;padding: 0 20px;width: 100%;height: auto' />
                                                                        </td>
                                                                    </tr>
                                                                </table>
                                                            </td>
                                                        </tr>
                                                    </table>
                                                </td>
                                            </tr>
                                        </table>
                                    </td>
                                </tr>
                            </table>
                            <table class='es-footer' cellspacing='0' cellpadding='0' align='center'>
                                <tr>
                                    <td align='center'>
                                        <table class='es-footer-body' width='600' cellspacing='0' cellpadding='0' bgcolor='#ffffff' align='center'>
                                            <tr>
                                                <td class='es-p20t es-p20b es-p20r es-p20l' align='left'>
                                                    <table cellspacing='0' cellpadding='0' width='100%'>
                                                        <tr>
                                                            <td width='560' align='left'>
                                                                <table width='100%' cellspacing='0' cellpadding='0' role='presentation'>
                                                                    <tr>
                                                                        <td align='center'>
                                                                            <p style='font-size: 20px'>Someone from our team will get in touch with you shortly</p>
                                                                        </td>
                                                                    </tr>
                                                                </table>
                                                            </td>
                                                        </tr>
                                                    </table>
                                                </td>
                                            </tr>
                                        </table>
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                </table>
            </div>
        </body>
        </html>
    ";
    
    if(!($mailer->send())){
        $mailer->ClearAllRecipients();
        ?><script>window.location.href = '../fail.html';</script><?php
    }
    else{
        $mailer->ClearAllRecipients();
        ?><script>window.location.href = "../success.html"</script><?php
    }
} 
catch (Exception $e) {
    echo "EMAIL SENDING FAILED. INFO: " . $mailer->ErrorInfo;
}