Guest User

Untitled

a guest
Jan 29th, 2015
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. <?php
  2. $key = "<API Key>";
  3. $from = "info@example.com";
  4. $to = "dave@example.com";
  5.  
  6.  
  7. if ($_SERVER['REQUEST_METHOD'] == 'POST') {
  8. if(isset($_POST['timestamp']) && isset($_POST['token']) && isset($_POST['signature']) && hash_hmac('sha256', $_POST['timestamp'] . $_POST['token'], $key) === $_POST['signature'])
  9. {
  10. if($_POST['event'] == 'complained') {
  11. $subject = "[Mailgun] Spam Complaint";
  12. $body = "Recipient: " . $_POST['recipient'] . "\nDomain: " . $_POST['domain'] . "\n\nMessage-headers: " . $_POST['message-headers'] . "\n";
  13. mail($to, $subject, $body, "From: " . $from,"-f". $from);
  14. }elseif($_POST['event'] == 'bounced'){
  15. $subject = "[Mailgun] Bounced Email";
  16. $body = "Recipient: " . $_POST['recipient'] . "\nDomain: " . $_POST['domain'] . "\nCode: " . $_POST['code'] . "\nError: " . $_POST['error'] . "\nNotification: " . $_POST['notification'] . "\n\nMessage-headers: " . $_POST['message-headers'] . "\n";
  17. mail($to, $subject, $body, "From: " . $from,"-f". $from);
  18. }elseif($_POST['event'] == 'dropped'){
  19. $subject = "[Mailgun] Failed Email";
  20. $body = "Recipient: " . $_POST['recipient'] . "\nDomain: " . $_POST['domain'] . "\nCode: " . $_POST['code'] . "\nReason: " . $_POST['reason'] . "\nDescription: " . $_POST['description'] . "\n\nMessage-headers: " . $_POST['message-headers'] . "\n";
  21. mail($to, $subject, $body, "From: " . $from,"-f". $from);
  22. }
  23. }
  24. }
  25. header('X-PHP-Response-Code: 200', true, 200);
  26. ?>
Add Comment
Please, Sign In to add comment