-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsendgrid.php
22 lines (22 loc) · 847 Bytes
/
sendgrid.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<?php
$html = 'YOUR_HTML_MAIL_FORMAT_HERE';
$string = array('to' => array('person@email.com','another_person@email.com'));
$params = array(
'api_user' => SNAPGRID_MAIL_USER,
'api_key' => SNAPGRID_MAIL_PASS,
'x-smtpapi' => json_encode($string),
'from' => 'noreply@piyushdolar.com',
'to' => 'person@email.com',
'subject' => 'Latest Mail From US',
'html' => $html,
);
$session = curl_init('https://api.sendgrid.com/api/mail.send.json');
curl_setopt($session, CURLOPT_POST, true);
curl_setopt($session, CURLOPT_POSTFIELDS, $params);
curl_setopt($session, CURLOPT_HEADER, false);
curl_setopt($session, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1_2);
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($session);
curl_close($session);
print_r($response);
?>