0xV3NOMx
Linux ip-172-26-7-228 5.4.0-1103-aws #111~18.04.1-Ubuntu SMP Tue May 23 20:04:10 UTC 2023 x86_64



Your IP : 18.223.159.143


Current Path : /var/www/html/admission/
Upload File :
Current File : /var/www/html/admission/sendGridMail.php

<?php

error_reporting(E_ALL);
/*$json_string = array(

  'to' => array(
    'example1@sendgrid.com', 'example2@sendgrid.com'
  ),
  'category' => 'test_category'
);
*/
function sendGridMail($to, $subject, $html,$univcode)
{
  if($univcode == '051')
  {
    $from = 'coe.qp@dypatil.edu';
  }else if($univcode == 'P005'){
    $from = 'Admissions@harshainstitutions.com';
  }else if($univcode == 'P001'){ 
    $from = 'Admissions@rrinstitutions.com';
  }else{
    $from = 'support@uniclare.com';
  }

  $url = 'https://api.sendgrid.com/';

  $token = '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';
  $params = array(

    'to'        => $to,
    'subject'   => $subject,
    'html'      => $html,
    'from'      => $from,
  );

  $request =  $url . 'api/mail.send.json';
  $headr = array();
  $headr[] = 'Authorization: Bearer ' . $token;
  // Generate curl request
  $session = curl_init($request);
  // Tell curl to use HTTP POST
  curl_setopt($session, CURLOPT_POST, true);
  // Tell curl that this is the body of the POST
  curl_setopt($session, CURLOPT_POSTFIELDS, $params);
  // Tell curl not to return headers, but do return the response
  curl_setopt($session, CURLOPT_HEADER, false);
  // Tell PHP not to use SSLv3 (instead opting for TLS)
  //curl_setopt($session, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1_2);
  curl_setopt($session, CURLOPT_RETURNTRANSFER, true);

  curl_setopt($session, CURLOPT_HTTPHEADER, $headr);

  // obtain response
  $response = curl_exec($session);
  curl_close($session);

  // print everything out
  return $response;
}