fork download
  1. <?php
  2.  
  3. // API endpoint URL
  4. $url = "https://d...content-available-to-author-only...o.com/v1.1/as/email";
  5.  
  6. // Payload containing email details
  7. $payload = [
  8. "Content" => [
  9. "Simple" => [
  10. "Body" => [
  11. "Html" => [
  12. "Charset" => "UTF-8",
  13. "Data" => "<p>Hello from Example</p>"
  14. ],
  15. "Text" => [
  16. "Charset" => "UTF-8",
  17. "Data" => "Hello from Example"
  18. ]
  19. ],
  20. "Subject" => [
  21. "Charset" => "UTF-8",
  22. "Data" => "Test subject"
  23. ]
  24. ]
  25. ],
  26. "Destination" => [
  27. "BccAddresses" => [
  28. "recipient1@example.com"
  29. ],
  30. "CcAddresses" => [
  31. "recipient2@example.com"
  32. ],
  33. "ToAddresses" => [
  34. "sanjay.ar+1@zohotest.com"
  35. ]
  36. ],
  37. "FeedbackForwardingEmailAddress" => "bounce@example.com",
  38. "FromEmailAddress" => "sender@dip.nashs.in",
  39. "ReplyToAddresses" => [
  40. "sender@dip.nashs.in"
  41. ]
  42. ];
  43.  
  44. // Headers containing authorization and content-type
  45. $headers = [
  46. "Authorization: Zoho-enczapikey OlyO55SFNR52zZVwfsDPjKW1zEyn96ULj3QQa6C6gTGQlXfjAR2hEJRXYXeeP8MkxaQb8PoDn6n1GcPYmXTN6Mr0U7r1r40KeItwz2yAguFPHC4cFJxdQGIvfrr+u5uqJUHTEiQ2t2m2tQ==",
  47. "Accept: application/json",
  48. "Content-Type: application/json"
  49. ];
  50.  
  51. // Initialize cURL session
  52. $ch = curl_init($url);
  53.  
  54. // Set cURL options
  55. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  56. curl_setopt($ch, CURLOPT_POST, true);
  57. curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  58. curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
  59.  
  60. // Execute the POST request
  61. $response = curl_exec($ch);
  62.  
  63. // Check for errors
  64. if ($response === false) {
  65. $error = curl_error($ch);
  66. echo "Error: $error";
  67. } else {
  68. // Parse and print the response
  69. $result = json_decode($response, true);
  70. print_r($result);
  71. }
  72.  
  73. // Close cURL session
  74.  
  75. ?>
Success #stdin #stdout 0.04s 26204KB
stdin
Standard input is empty
stdout
Error: Could not resolve host: devtransmail.localzoho.com