Advertisement
Guest User

Untitled

a guest
Feb 9th, 2017
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. <?php
  2. $url = 'https://api.sendgrid.com/';
  3. $user = 'username that I saved';
  4. $pass = 'password that I created';
  5.  
  6. $params = array(
  7. 'api_user' => $user,
  8. 'api_key' => $pass,
  9. 'to' => 'mymailaddress@mail.com',
  10. 'subject' => 'testing from curl',
  11. 'html' => 'testing body',
  12. 'text' => 'testing body',
  13. 'from' => 'anna@contoso.com',
  14. );
  15.  
  16. $request = $url.'api/mail.send.json';
  17.  
  18. // Generate curl request
  19. $session = curl_init($request);
  20.  
  21. // Tell curl to use HTTP POST
  22. curl_setopt ($session, CURLOPT_POST, true);
  23.  
  24. // Tell curl that this is the body of the POST
  25. curl_setopt ($session, CURLOPT_POSTFIELDS, $params);
  26.  
  27. // Tell curl not to return headers, but do return the response
  28. curl_setopt($session, CURLOPT_HEADER, false);
  29. curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
  30.  
  31. // obtain response
  32. $response = curl_exec($session);
  33. curl_close($session);
  34.  
  35. // print everything out
  36. print_r($response);
  37. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement