| Server IP : 192.169.170.185 / Your IP : 216.73.216.97 Web Server : Apache System : Linux p3plmcpnl495852.prod.phx3.secureserver.net 4.18.0-553.52.1.lve.el8.x86_64 #1 SMP Wed May 21 15:31:29 UTC 2025 x86_64 User : akhilnew ( 1712764) PHP Version : 5.6.40 Disable Function : NONE MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/akhilnew/public_html/ |
Upload File : |
<?php
class Sendgrid {
public $reply = '', $replyEmail = '', $from = '', $fromEmail = '', $cc = '', $bcc = '';
public function send($to = null, $subject = null, $body = null, array $attachmentFiles = null)
{
if (is_null($to) OR is_null($subject) OR is_null($body)) {
return false;
}
$headers = array(
'Authorization: Bearer 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',
'Content-Type: application/json'
);
$data = array(
'personalizations' => array(
array(
'to' => array(
array(
'email' => $to,
)
)
)
),
'from' => array(
'email' => $this->fromEmail,
'name' => $this->from,
),
'reply_to' => array(
'email' => $this->replyEmail,
'name' => $this->reply,
),
'subject' => $subject,
'content' => array(
array(
'type' => 'text/html',
'value' => $body
)
)
);
if ($this->cc) {
foreach (explode(',', $this->cc) as $k => $cc) {
$ccs[$k]['email'] = trim($cc);
}
$data['personalizations'][0]['cc'] = $ccs;
}
if ($this->bcc) {
foreach (explode(',', $this->bcc) as $k => $bcc) {
$bccs[$k]['email'] = trim($bcc);
}
$data['personalizations'][0]['bcc'] = $bccs;
}
if ($attachmentFiles && ! empty($attachmentFiles)) {
foreach ($attachmentFiles as $k => $attachment) {
$attachments[$k]['content'] = base64_encode(file_get_contents($attachment));
$attachments[$k]['type'] = 'text/html';
$attachments[$k]['filename'] = $attachment;
}
$data['attachments'] = $attachments;
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.sendgrid.com/v3/mail/send');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_exec($ch);
curl_close($ch);
}
}
$sendgrid = new Sendgrid();
// $sendgrid->from = 'TPI';
// $sendgrid->fromEmail = 'info@thepharmajournal.com';
// $sendgrid->reply = 'Akinik Subs';
// $sendgrid->replyEmail = 'akiniksubs@gmail.com';
// $sendgrid->send('akinikbooks@gmail.com', 'This is subject', 'This is message '.date('d/m/Y h:i:s A').PHP_EOL.PHP_EOL);
// $sendgrid->reply = 'Akinik Books';
// $sendgrid->replyEmail = 'akinikbooks@gmail.com';
// $sendgrid->send('akiniksubs@gmail.com', 'This is subject', 'This is message '.date('d/m/Y h:i:s A').PHP_EOL.PHP_EOL);
?>