Advertisement
Guest User

Untitled

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