Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $url = 'https://api.sendgrid.com/';
- $user = 'MY_USER_ID';
- $pass = 'MY_PASSWORD';
- $fileName = 'week-19.pdf';
- $filePath = dirname(__FILE__);
- $params = array(
- 'api_user' => $user,
- 'api_key' => $pass,
- 'to' =>'test@test.com',
- 'subject' => 'Sendgrid test of file sends',
- 'html' => '<p> the HTML </p>',
- 'text' => 'the plain text',
- 'from' => 'anna@test.com',
- 'files['.$fileName.']' => '@'.$filePath.'/'.$fileName
- );
- print_r($params);
- $request = $url.'api/mail.send.json';
- // Generate curl request
- $session = curl_init($request);
- // Tell curl to use HTTP POST
- curl_setopt ($session, CURLOPT_POST, true);
- // Tell curl that this is the body of the POST
- curl_setopt ($session, CURLOPT_POSTFIELDS, $params);
- // Tell curl not to return headers, but do return the response
- curl_setopt($session, CURLOPT_HEADER, false);
- curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
- // obtain response
- $response = curl_exec($session);
- curl_close($session);
- // print everything out
- print_r($response);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement