Advertisement
Guest User

Untitled

a guest
Jan 25th, 2017
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. <?php
  2.  
  3. namespace SendGrid;
  4. //require 'vendor/autoload.php';
  5. require("C:UsersSiddhiDownloadssendgrid-phpsendgrid-php");
  6.  
  7. class SendEmail
  8. {
  9. private $db;
  10.  
  11. function SendEmail($database){
  12. $this->db = $database;
  13. }
  14.  
  15. function helloEmail()
  16. {
  17. $from = new Email(null, "siddhijambhale@gmail.com");
  18. $subject = "Hello World from the SendGrid PHP Library";
  19. $to = new Email(null, "siddhijambhale@gmail.com");
  20. $content = new Content("text/plain", "send grid test email");
  21. $mail = new Mail($from, $subject, $to, $content);
  22. $to = new Email(null, "siddhijambhale@gmail.com");
  23. $mail->personalization[0]->addTo($to);
  24. //echo json_encode($mail, JSON_PRETTY_PRINT), "n";
  25.  
  26. echo $to;
  27. return $mail;
  28. }
  29.  
  30. function sendHelloEmail()
  31. {
  32. $apiKey = getenv(key here');
  33. $sg = new SendEmail($apiKey);
  34. $request_body = $this->helloEmail();
  35. $response = $sg->client->mail()->send()->post($request_body);
  36. echo $response->statusCode();
  37. echo $response->body();
  38. echo $response->headers();
  39.  
  40. return $request_body;
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement