Last active
July 6, 2019 09:38
-
-
Save FredSRocha/708b3fff6d3465355be1b75047cf0ed2 to your computer and use it in GitHub Desktop.
Send Grid Class.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
interface IEmail { | |
public static function sendGrid($email,$subject,$htmlmessage,$plaintext); | |
} | |
class SendGridEmail implements IEmail { | |
public static function sendGrid($email,$subject,$htmlmessage,$plaintext) { | |
$url = 'https://api.sendgrid.com/'; | |
$user = '***'; // SendGrid User. | |
$pass = '***'; // SendGrid Password. | |
$params = array( | |
'api_user' => $user, | |
'api_key' => $pass, | |
'to' => $email, | |
'subject' => $subject, | |
'html' => $htmlmessage, | |
'text' => $plaintext, | |
'from' => '***@email.com', | |
); | |
$request = $url.'api/mail.send.json'; | |
$session = curl_init($request); | |
curl_setopt ($session, CURLOPT_POST, true); | |
curl_setopt ($session, CURLOPT_POSTFIELDS, $params); | |
curl_setopt($session, CURLOPT_HEADER, false); | |
curl_setopt($session, CURLOPT_RETURNTRANSFER, true); | |
$response = curl_exec($session); | |
curl_close($session); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment