<?php

class Emailpro{

    public function sendemail($details)
        { 
       
        require("sendgrid/sendgrid-php.php");
        $email = new \SendGrid\Mail\Mail();
        $email->setFrom($details['email'],$details['names']);
        $email->setSubject($details['subject']);
        $email->addTo("protendai@gmail.com","H2O Hosting");
        $email->addContent(
            "text/html",
            "Phone number :".$details['phone']."<br/>".$details['message']."<br/><br/>Regards, ".$details['names']."<br><br/> Sent from Website"
        );
        $apikey = "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";
        $sendgrid = new \SendGrid($apikey);
        try {
            $response = $sendgrid->send($email);
            $response->statusCode();
            $response->headers();
            $response->body();
            //print_r($response->statusCode());
            if ($response->statusCode() != 202) {
                $message = false;
                return $message;
            }
            $message = true;
            return $message;
        } catch (Exception $e) {
            $e->getMessage();
            $message = false;
            return $message;
        }
    }


    public function getQuote($details){
        
        require("sendgrid/sendgrid-php.php");
        $email = new \SendGrid\Mail\Mail();
        $email->setFrom($details['email'],$details['names']);
        $email->setSubject($details['subject']);
        $email->addTo("protendai@gmail.com","H2O Hosting");
        $email->addContent(
            "text/html",
            "<b>Customer name</b> ".$details['names']."<br/><b> Is requesting for </b> ".$details['service']." <br/> <b>Request description</b> ".$details['descr'] . "<br><br/> Sent from Website"
        );
        $apikey = "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";
        $sendgrid = new \SendGrid($apikey);
        try {
            $response = $sendgrid->send($email);
            $response->statusCode();
            $response->headers();
            $response->body();
            //print_r($response->statusCode());
            if ($response->statusCode() != 202) {
                $message = false;
                return $message;
            }
            $message = true;
            return $message;
        } catch (Exception $e) {
            $e->getMessage();
            $message = false;
            return $message;
        }
    }
}
?>