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 : 3.144.98.43
Current Path : /var/www/html/sms/ |
| Current File : /var/www/html/sms/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)
{
$url = 'https://api.sendgrid.com/';
$token = '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';
$params = array(
'to' => $to,
'subject' => $subject,
'html' => $html,
'from' => 'support@uniclare.com',
);
$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;
}
|