wheelsmanx

REST API EMAIL SENDER

May 10th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. // sends an email with the data that is sent to it from rest api
  2. // takes all incoming POST data and sends it to email
  3.  
  4. <?php
  5. // this is how to respond to a post request
  6. // we are sending the response array to the request
  7. $youremailaddress = "************";
  8. $response = $_POST;
  9. foreach ($_POST as $key => $value){
  10. $message .= htmlspecialchars($key)." \t\t\t ".htmlspecialchars($value)."\n";
  11. }
  12. mail($youremailaddress , 'sghting', $message);
  13. Header("Content-Type: application/json;charset=UTF-8");
  14. $data = json_encode($response);
  15. $len = strlen($data);
  16. // Some browser/proxy/load balancer may get better performance if the
  17. // length is known beforehand. This also disables Chunked-Encoding, which
  18. // in some scenarios may give problems.
  19. Header("Content-Length: {$len}");
  20. die($data);
  21. $doubletest = " ";
  22.  
  23. ?>
Advertisement
Add Comment
Please, Sign In to add comment