Guest User

Untitled

a guest
Apr 12th, 2018
498
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.34 KB | None | 0 0
  1. curl -H 'api-key:your_access_key' -X POST -d '{"cc":["cc@example.net":"cc whom!"],"text":"This is the text","bcc":["bcc@example.net":"bcc whom!"],"replyto":["replyto@email.com","reply to!"],"html":"This is the <h1>HTML</h1>This is inline image 1.<br/><img src="{myinlineimage1.png}" alt="image1" border="0"><br/>Some text<br/>This is inline image 2.<br/><img src="{myinlineimage2.jpg}" alt="image2" border="0"><br/>Some more text<br/>Re-used inline image 1.<br/><img src="{myinlineimage1.png}" alt="image3" border="0">","to":{"to@example.net":"to whom!"},"attachment": {"myfilename.pdf":"your_pdf_files_base64_encoded_chunk_data"},"from":["from@email.com","from email!"],"subject":"My subject","headers":{"Content-Type":"text/html; charset=iso-8859-1", "X-param1":"value1","X-param2":"value2", "X-Mailin-custom":"my custom value","X-Mailin-IP":"102.102.1.2", "X-Mailin-Tag":"My tag"},"inline_image":{"myinlineimage1.png":"your_png_files_base64_encoded_chunk_data", "myinlineimage2.jpg":"your_jpg_files_base64_encoded_chunk_data"}}' 'https://api.sendinblue.com/v2.0/email
  2.  
  3. $senddata = array (
  4. 'to' => array('sample_mail@live.com'=>'sample_mail@live.com'),
  5. 'from' => array($fromvalue,$fromvalue),
  6. 'replyto' => array("user_mail@live.com","user_mail@live.com"),
  7. 'subject' => "subject",
  8. 'text' => "text",
  9. 'html' => '',
  10. 'fromname' => $fromnamevalue,
  11. 'bcc' => 'bcc'
  12. );
  13.  
  14. $ch = curl_init();
  15.  
  16. curl_setopt($ch, CURLOPT_URL, "https://api.sendinblue.com/v2.0/email");
  17. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  18. curl_setopt($ch, CURLOPT_POSTFIELDS, "{"cc":["cc@example.net":"cc whom!"],"text":"This is the text","bcc":["bcc@example.net":"bcc whom!"],"replyto":["replyto@email.com","reply to!"],"html":"This is the <h1>HTML</h1>This is inline image 1.<br/><img src="{myinlineimage1.png}" alt="image1" border="0"><br/>Some text<br/>This is inline image 2.<br/><img src="{myinlineimage2.jpg}" alt="image2" border="0"><br/>Some more text<br/>Re-used inline image 1.<br/><img src="{myinlineimage1.png}" alt="image3" border="0">","to":{"to@example.net":"to whom!"},"attachment": {"myfilename.pdf":"your_pdf_files_base64_encoded_chunk_data"},"from":["from@email.com","from email!"],"subject":"My subject","headers":{"Content-Type":"text/html; charset=iso-8859-1", "X-param1":"value1","X-param2":"value2", "X-Mailin-custom":"my custom value","X-Mailin-IP":"102.102.1.2", "X-Mailin-Tag":"My tag"},"inline_image":{"myinlineimage1.png":"your_png_files_base64_encoded_chunk_data", "myinlineimage2.jpg":"your_jpg_files_base64_encoded_chunk_data"}}");
  19. curl_setopt($ch, CURLOPT_POST, 1);
  20.  
  21. $headers = array();
  22. $headers[] = "Api-Key: your_access_key";
  23. $headers[] = "Content-Type: application/x-www-form-urlencoded";
  24. curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  25.  
  26. $result = curl_exec($ch);
  27. if (curl_errno($ch)) {
  28. echo 'Error:' . curl_error($ch);
  29. }
  30. curl_close ($ch);
  31.  
  32. curl_setopt($ch, CURLOPT_POSTFIELDS,$senddata);
  33.  
  34. $request = new HttpRequest();
  35. $request->setUrl('https://api.sendinblue.com/v2.0/email');
  36. $request->setMethod(HTTP_METH_POST);
  37.  
  38. $request->setHeaders(array(
  39. 'api-key' => 'your_access_key',
  40. ));
  41.  
  42. $request->setBody('{
  43. "cc":["cc@example.net":"cc whom!"],
  44. "text":"This is the text",
  45. "bcc":["bcc@example.net":"bcc whom!"],
  46. "replyto":["replyto@email.com","reply to!"],
  47. "html":"This is the <h1>HTML</h1>This is inline image 1.<br/><img src="{myinlineimage1.png}" alt="image1" border="0"><br/>Some text<br/>This is inline image 2.<br/><img src="{myinlineimage2.jpg}" alt="image2" border="0"><br/>Some more text<br/>Re-used inline image 1.<br/><img src="{myinlineimage1.png}" alt="image3" border="0">",
  48. "to":{"to@example.net":"to whom!"},
  49. "attachment": {
  50. "myfilename.pdf":"your_pdf_files_base64_encoded_chunk_data"
  51. },
  52. "from":["from@email.com","from email!"],
  53. "subject":"My subject",
  54. "headers":{
  55. "Content-Type":"text/html; charset=iso-8859-1",
  56. "X-param1":"value1",
  57. "X-param2":"value2",
  58. "X-Mailin-custom":"my custom value",
  59. "X-Mailin-IP":"102.102.1.2",
  60. "X-Mailin-Tag":"My tag"
  61. },
  62. "inline_image":{
  63. "myinlineimage1.png":"your_png_files_base64_encoded_chunk_data",
  64. "myinlineimage2.jpg":"your_jpg_files_base64_encoded_chunk_data"
  65. }
  66. }');
  67.  
  68. try {
  69. $response = $request->send();
  70.  
  71. echo $response->getBody();
  72. } catch (HttpException $ex) {
  73. echo $ex;
  74. }
Add Comment
Please, Sign In to add comment