
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception;
                                                                                         <?php
function send_email($email,$name, $subject, $body)
{ 

    /* SMTP */

//	require_once 'PHPMailer/PHPMailerAutoload.php';
    $mail->isSMTP();
        $mail->Host = SMTP_HOST;  // Specify main and backup SMTP servers
       // $mail->Host = 'localhost';
        $mail->SMTPAuth = true;                               // Enable SMTP authentication
      //  $mail->SMTPAuth = false; 
        $mail->Username = SMTP_EMAIL;                 // SMTP username
        $mail->Password = SMTP_PASSWORD;
        $mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS;   // Enable TLS encryption; `PHPMailer::ENCRYPTION_SMTPS` also accepted
        $mail->Port = SMTP_PORT;
       // $mail->Port = 25;
        $mail->CharSet  = 'UTF-8';

        /*$mail->SMTPOptions = array(
            'ssl' => array(
                'verify_peer' => false,
                'verify_peer_name' => false,
                'allow_self_signed' => true
            )
        );*/

        $mail->setFrom(SMTP_SET_FROM_EMAIL, SMTP_SET_FROM_NAME);


        if(is_array($email))
        {
            $mail->addAddress(SMTP_SET_FROM_EMAIL, SMTP_SET_FROM_NAME);
            foreach($email AS $each)
            {
                $mail->addBcc($each['email']);
            }
        }
        else
        {
            $mail->addAddress($email, $name);
        }

      
	
        $mail->Subject = $subject;


        $logo = '';
        if($noLogo == null || $noLogo == 0)
        {
            $logo = '<img src="https://www.axo.lv/ACP/images/logo.png" style="max-width:150px" />';
        }

        //$bodyEmail = '<!DOCTYPE html><head></head><title></title><body>';
        $bodyEmail = '';
        if($noFrame == 0)
        {
            $bodyEmail.= '<table style="width:800px;max-width:100%;border:1px solid lightgray;text-align:center;margin : 0 auto"><tr><td style="text-align:left;border-bottom:1px solid lightgray;;padding:15px">' . $logo . '</td></tr><tr><td><b style="font-size:17px;;padding:15px">';
        }

        $bodyEmail.= $body;

        if($noFrame == 0)
        {
            $bodyEmail.= '</b></td></tr><tr><td style="border-top:1px solid lightgray;padding:15px">Paldies, ka izvēlējāties<br/>www.axo.lv</td></tr></table>';
        }

        $mail->Body    = $bodyEmail;
        $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
        
        	$mail->isHTML(true);

        if($attachments != null)
        {
            foreach($attachments AS $attachment)
            {
                $mail->addAttachment($attachment); 
            }
            
        }
        
      

        if(!$mail->send())
        {
            return 0;
        }
        else
        {
            return 1;
        }
/*ini_set('sendmail_from', 'noreplay@clusterinfos.com');
ini_set('sendmail_path', '/usr/sbin/sendmail -t -i -f noreplay@clusterinfos.com');
$headers = "From: noreplay@clusterinfos.com\n"; // This is the email address the generated message will be from. We recommend using something like noreply@yourdomain.com.
						//$headers .= "Reply-To: shayasmk@gmail.com\r\n";
						$headers .= "MIME-Version: 1.0\r\n";
						$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
						$headers .= "X-Mailer: PHP/".phpversion();   

						return mail('shayasmk@gmail.com',$subject, $body, $headers); */

}
