<?php

class Emailpro{

    public function sendemail($details)
        { 
      
        $mail     = $details['email'];  // send email to this address
        $name       = $details['names'];    // name of customer
        $subject    = $details['subject']; // message subject
        $message    = $details['message']; // message to customer

        require("sendgrid/sendgrid-php.php");
    
        $email = new \SendGrid\Mail\Mail(); 
        $email->setFrom("protendai@outlook.com", "Pillarstone Website");
        $email->setSubject($subject);
        $email->addTo("karumatendai@gmail.com","Pillarstone Website");
        $email->addContent("text/html",$message ."<br/><br/> From ".$name." Email :".$mail);
     
        
        $sendgrid = new \SendGrid('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');
        try {
            $response = $sendgrid->send($email);
            return $response;
        } catch (Exception $e) {
            $message = $e->getMessage();
            return $message;
        }
    }
}
?>